diff --git a/jarvis/main.py b/jarvis/main.py index 2c5f07f..6985077 100644 --- a/jarvis/main.py +++ b/jarvis/main.py @@ -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() diff --git a/jarvis/skills/entertainement/decide/__init__.py b/jarvis/skills/entertainement/decide/__init__.py new file mode 100644 index 0000000..c40b1e3 --- /dev/null +++ b/jarvis/skills/entertainement/decide/__init__.py @@ -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) diff --git a/jarvis/skills/entertainement/decide/regex/en-us/Choice1.rx b/jarvis/skills/entertainement/decide/regex/en-us/Choice1.rx new file mode 100755 index 0000000..4c9000d --- /dev/null +++ b/jarvis/skills/entertainement/decide/regex/en-us/Choice1.rx @@ -0,0 +1,2 @@ +(.* (?P.*) or (?P.*)) +between ((?P.*) and (?P.*)) \ No newline at end of file diff --git a/jarvis/skills/entertainement/decide/regex/en-us/Choice2.rx b/jarvis/skills/entertainement/decide/regex/en-us/Choice2.rx new file mode 100755 index 0000000..e48b4b3 --- /dev/null +++ b/jarvis/skills/entertainement/decide/regex/en-us/Choice2.rx @@ -0,0 +1,2 @@ +(.* (?P.*) or (?P.*)) +between ((?P.*) and (?P.*)) diff --git a/jarvis/skills/entertainement/decide/regex/fr-fr/choice1.rx b/jarvis/skills/entertainement/decide/regex/fr-fr/choice1.rx new file mode 100644 index 0000000..1907bf9 --- /dev/null +++ b/jarvis/skills/entertainement/decide/regex/fr-fr/choice1.rx @@ -0,0 +1 @@ +(?P\w+|(\w+ au \w+)) (?:ou|et) (?P\w+|(\w+ au \w+)) \ No newline at end of file diff --git a/jarvis/skills/entertainement/decide/regex/fr-fr/choice2.rx b/jarvis/skills/entertainement/decide/regex/fr-fr/choice2.rx new file mode 100644 index 0000000..25240e9 --- /dev/null +++ b/jarvis/skills/entertainement/decide/regex/fr-fr/choice2.rx @@ -0,0 +1 @@ +(?P\w+|(\w+ au \w+)) (?:ou|et) (?P\w+|(\w+ au \w+)) \ No newline at end of file diff --git a/jarvis/skills/entertainement/decide/vocab/en-us/DecideKeyword.voc b/jarvis/skills/entertainement/decide/vocab/en-us/DecideKeyword.voc new file mode 100755 index 0000000..27c27d2 --- /dev/null +++ b/jarvis/skills/entertainement/decide/vocab/en-us/DecideKeyword.voc @@ -0,0 +1,4 @@ +Decide +What should I wear +What should I eat +game \ No newline at end of file diff --git a/jarvis/skills/entertainement/decide/vocab/fr-fr/OrKeyword.voc b/jarvis/skills/entertainement/decide/vocab/fr-fr/OrKeyword.voc new file mode 100644 index 0000000..bcfc20a --- /dev/null +++ b/jarvis/skills/entertainement/decide/vocab/fr-fr/OrKeyword.voc @@ -0,0 +1,3 @@ +ou +et +entre \ No newline at end of file diff --git a/jarvis/skills/entertainement/decide/vocab/fr-fr/decide.intent b/jarvis/skills/entertainement/decide/vocab/fr-fr/decide.intent new file mode 100644 index 0000000..f98a9ba --- /dev/null +++ b/jarvis/skills/entertainement/decide/vocab/fr-fr/decide.intent @@ -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}