added decide skill

This commit is contained in:
Mathieu B 2021-08-01 21:07:03 +02:00
parent d5c76e3b91
commit d90079873c
9 changed files with 54 additions and 0 deletions

View File

@ -1,6 +1,7 @@
import lingua_franca
from jarvis.skills import intent_manager
from jarvis.skills.entertainement.decide import DecideSkill
from jarvis.skills.entertainement.jokes import JokesSkill
from jarvis.skills.entertainement.spotify import SpotifySkill
from jarvis.skills.productivity.speedtest import SpeedTestSkill
@ -17,6 +18,7 @@ if __name__ == '__main__':
JokesSkill().register()
SpotifySkill().register()
SpeedTestSkill().register()
DecideSkill().register()
# Load all skills
intent_manager.load_all_skills()

View File

@ -0,0 +1,32 @@
import random
from adapt.intent import IntentBuilder
from jarvis.skills import Skill, SkillRegistering
from jarvis.skills.decorators import intent_handler
class DecideSkill(Skill, metaclass=SkillRegistering):
def __init__(self, data=dict):
super().__init__("DecideSkill", data)
@intent_handler(IntentBuilder("DecideIntent").require("choice1").require("choice2").optionally("OrKeyword"))
# @intent_file_handler("decide.intent", "DecideIntent")
def handle_decide(self, data):
print("decide")
print(data)
if 'choice1' in data and 'choice2' in data:
choice = bool(random.getrandbits(1))
if choice:
self.speak(data['choice1'])
else:
self.speak(data['choice2'])
else:
print("no all choice")
def create_skill(data):
return DecideSkill(data)

View File

@ -0,0 +1,2 @@
(.* (?P<Choice1>.*) or (?P<dummy>.*))
between ((?P<Choice1>.*) and (?P<dummy>.*))

View File

@ -0,0 +1,2 @@
(.* (?P<dummy2>.*) or (?P<Choice2>.*))
between ((?P<dummy2>.*) and (?P<Choice2>.*))

View File

@ -0,0 +1 @@
(?P<choice1>\w+|(\w+ au \w+)) (?:ou|et) (?P<dummy>\w+|(\w+ au \w+))

View File

@ -0,0 +1 @@
(?P<dummy>\w+|(\w+ au \w+)) (?:ou|et) (?P<choice2>\w+|(\w+ au \w+))

View File

@ -0,0 +1,4 @@
Decide
What should I wear
What should I eat
game

View File

@ -0,0 +1,3 @@
ou
et
entre

View File

@ -0,0 +1,7 @@
(décide|choisis|choisi) entre {choice1} (et|ou) {choice2}
qui-est ce qui va gagner {choice1} ou {choice2}
tu pense (que|) c'est {choice1} ou {choice2} qui gagne
entre {choice1} et {choice2}
{choice1} ou {choice2}
tu prefère (le|les|la) {choice1} (ou|ou bien) (le|les|la) {choice2}
choisi entre {choice1} et {choice2}