コード例 #1
0
 def create():
     return Folder(label="Color",
                   children=[
                       Concept(_id="red",
                               grammars=[Grammar(watson_items=["red"])]),
                       Concept(_id="white",
                               grammars=[Grammar(watson_items=["white"])]),
                       Concept(_id="black",
                               grammars=[Grammar(watson_items=["black"])])
                   ])
コード例 #2
0
 def create():
     return Output(
         _id=StartSearch.__id(),
         prompt=Prompt(
             items=["Would you like to find a specific style of shoe?"]
             # "Would you like to find a movie that's now playing or coming soon?"
         ),
         children=[
             GetUserInput(children=[
                 # TODO Not sure how this is useful
                 # (0, "input"): {
                 #     (0, "grammar"): {
                 #         "item": "$ (DATE_TIME_RANGE)={DateTime_Mentioned_ENT}"
                 #     },
                 #     (1, "action"): {
                 #         "@varName": "DateTime_Current",
                 #         "@operator": "SET_TO",
                 #         "#text": "<mct:getTime>America/Tijuana</mct:getTime>"
                 #     },
                 #     (2, "goto"): Goto(ref="input_date_time")
                 # },
                 Input(Grammar(
                     watson_items=["neither", "neither", "$ either", "no"]),
                       children=[
                           Output(prompt=GenericPrompt.ok(),
                                  children=[HowCanHelpYouOutput.goto()])
                       ]),
                 Input(
                     GenericGrammar.yes_okay(wildcard=False),
                     children=[
                         Output(Prompt(items=[
                             "Please tell me the style you would like then.",
                             "Ok great what style would you like?"
                         ]),
                                children=[
                                    StylePreferenceProfileCheckInput.goto()
                                ])
                     ]),
                 Input(Grammar(watson_items=[
                     "My name is", "$ my name is", "$ I am", "$ I'm",
                     "$ called", "$ call me", "$ known as"
                 ]),
                       children=[
                           Output(prompt=Prompt(items=["Sorry."]),
                                  children=[
                                      Goto(ref="input_user_knownas_name")
                                  ])
                       ]),
                 PreliminarySequencesSearch.goto()
             ])
         ])
コード例 #3
0
 def create_my_name_is_dynamic_data():
     return Grammar(
         watson_items=[
             "My name is", "$ my name is (DYNAMIC_DATA)={User_Name}",
             "$ I am (DYNAMIC_DATA)={User_Name}",
             "$ I'm (DYNAMIC_DATA)={User_Name}",
             "$ called (DYNAMIC_DATA)={User_Name}",
             "$ call me (DYNAMIC_DATA)={User_Name}",
             "$ known as (DYNAMIC_DATA)={User_Name}",
             "$ (DYNAMIC_DATA)={User_Name}"
         ],
         items=[
             RegExGrammarItem(pattern=r"\w*My name is (\w{1,3})",
                              dynamic_field_assignments=["User_Name"]),
             RegExGrammarItem(pattern=r"\w*My name (\w{1,3})",
                              dynamic_field_assignments=["User_Name"]),
             RegExGrammarItem(pattern=r"\w*I am called (\w{1,3})",
                              dynamic_field_assignments=["User_Name"]),
             RegExGrammarItem(pattern=r"\w*I am (\w{1,3})",
                              dynamic_field_assignments=["User_Name"]),
             RegExGrammarItem(pattern=r"\w*I'm called (\w{1,3})",
                              dynamic_field_assignments=["User_Name"]),
             RegExGrammarItem(pattern=r"\w*I'm (\w{1,3})",
                              dynamic_field_assignments=["User_Name"]),
             RegExGrammarItem(pattern=r"\w*called (\w{1,3})",
                              dynamic_field_assignments=["User_Name"]),
             RegExGrammarItem(pattern=r"\w*call me (\w{1,3})",
                              dynamic_field_assignments=["User_Name"]),
             RegExGrammarItem(pattern=r"\w*call me (\w{1,3})",
                              dynamic_field_assignments=["User_Name"]),
             RegExGrammarItem(pattern=r"\w*known as (\w{1,3})",
                              dynamic_field_assignments=["User_Name"]),
             RegExGrammarItem(pattern=r"(\w{1})",
                              dynamic_field_assignments=["User_Name"])
         ])
コード例 #4
0
    def create():
        return Folder(
            label="UI ACTIONS",
            children=[
                Input(
                    Grammar(watson_items=["USER CLICKS BOX"]),
                    children=[
                        Output(
                            prompt=Prompt(
                                items=["{Selected_Movie}."]
                            ),
                            children=[
                                If(
                                    elements=[
                                        Condition(name="Popularity_Score", operator="GREATER_THEN", root_text="6.9"),
                                        Output(
                                            Prompt(
                                                items=[
                                                    "Great choice! That gets fabulous ratings.",
                                                    "That's a good one! You will love it.",
                                                    " I hear that's a really good movie!"
                                                ]
                                            ),
                                            children=[AfterSearchResults.goto()]
                                        )
                                    ]
                                ),
                                If(
                                    elements=[
                                        Condition(name="Popularity_Score", operator="LESS_THEN", root_text="4"),
                                        Output(
                                            Prompt(
                                                items=[
                                                    "Hmm, I hear that's not such a great movie.",
                                                    "Um, that one gets low ratings.",
                                                    "Are you sure about that? The ratings are terrible."
                                                ]
                                            ),
                                            children=[AfterSearchResults.goto()]
                                        )

                                    ]
                                ),
                                Output(
                                    prompt=Prompt(
                                        items=[
                                            "Okay.",
                                            "All right.",
                                            "Sure thing!",
                                            "Coming right up!"
                                        ]
                                    ),
                                    children=[AfterSearchResults.goto()]
                                )
                            ]
                        )
                    ]
                )
            ]
        )
コード例 #5
0
 def create_ok_thanks():
     return Grammar(watson_items=[
         "okay", "ok", "thanks", "thank you", "ok thanks", "ok thank you",
         "okay thanks", "okay thank you", "all right", "alright", "great",
         "cool", "aww", "awww", "oh", "oh okay", "oh ok", "ah", "ah okay",
         "ah ok", "got it", "gotcha"
     ])
コード例 #6
0
 def create():
     return Input(
         Grammar(
             watson_items=[
                 "Favorites",
                 "$ favorites",
                 "$ favorite movies",
                 "$ favorited",
                 "$ hearted"
             ]
         ),
         children=[
             GreetingAction.reset(),
             SmallTalkAction.set_to_zero(),
             Output(
                 Prompt(
                     items=[
                         "When you get the details for a movie, you can save the movie in your <i>Favorites</i> by clicking on the heart icon above the trailer."]
                 ),
                 children=[
                     GetUserInput(
                         children=[
                             Input(
                                 GenericGrammar.ok(),
                                 children=[HowCanHelpYouOutput.goto()]
                             ),
                             PreliminarySequencesSearch.goto()
                         ]
                     )
                 ]
             )
         ]
     )
コード例 #7
0
 def create():
     return Input(
         Grammar(watson_items=["again", "$ again", "$ one more time"]),
         children=[
             PageAction.set_to_repeat(),
             Goto(ref="output_ok_do_search")
         ])
コード例 #8
0
 def create_sorry():
     return Grammar(watson_items=[
         "sorry", "apologize", "I am sorry", "I apologise", "I apologize",
         "apologies", "my apology", "my apologies", "so sorry",
         "very sorry", "extremely sorry", "extremely apologetic", "soz",
         "sozz", "so soz", "so sozz"
     ])
コード例 #9
0
 def create_yes_full():
     return Grammar(watson_items=[
         "yes", "yep", "yup", "yeah", "yeh", "y", "that's right", "sure",
         "yes thanks", "yes thank you", "yes please", "yah", "ya",
         "for sure", "fo shizzle", "fo shiz", "yeppers", "you betcha",
         "you bet", "you bet ya", "certainly"
     ])
コード例 #10
0
 def create(goto: Goto):
     return Input(
         Grammar(watson_items=[
             "rated",  # TODO find out what they were thinking with this
             "$(Color)={Color_Preference}"
         ]),
         _id=ColorPreferenceInput.__id(),
         children=[ColorPreferenceAction.set_to_value(), goto])
コード例 #11
0
 def create_preliminaries():
     return Grammar(watson_items=[
         "Preliminaries", "$ what do you know", "$ what can you do",
         "$ what can I do", "$ what can you tell", "$ what kind of",
         "$ what else do you know", "$ what do you have information",
         "$ do you know", "$ can you", "$ do you have information",
         "$ can I"
     ])
コード例 #12
0
 def create():
     return Folder(
         label="Style",
         children=[
             Concept(
                 _id="high heels",
                 grammars=[
                     Grammar(watson_items=["high heels", "high-heels"])
                 ]
             ),
             Concept(
                 _id="boots",
                 grammars=[
                     Grammar(watson_items=["boots", "boot"])
                 ]
             )
         ]
     )
コード例 #13
0
 def create():
     return Folder(
         _id="folder_routing_sequences",
         label="ROUTING SEQUENCES",
         children=[
             GreetingAction.reset(),
             SmallTalkAction.set_to_zero(),
             Input(Grammar(watson_items=[
                 "out-of-scope movie topics", "$ (OTHER_MOVIE)={Topic}"
             ]),
                   children=[
                       TopicAction.set_to_value(),
                       Goto(ref="output_no_topic_lookup")
                   ]),
             Input(Grammar(watson_items=[
                 "by out-of-scope movie topics",
                 "$ (BY_OTHER_MOVIE)={Topic}"
             ]),
                   children=[
                       TopicAction.set_to_value(),
                       Goto(ref="output_2503370")
                   ]),
             Input(Grammar(watson_items=[
                 "unsupported genres", "$ (UNSUPPORTED_GENRES)={Topic}"
             ]),
                   children=[
                       TopicAction.set_to_value(),
                       Goto(ref="output_2510164")
                   ]),
             Input(Grammar(watson_items=[
                 "old movies", "$ old movies", "$ classic movies",
                 "$ oldies", "$ classics"
             ]),
                   children=[Goto(ref="output_2503380")]),
             Input(Grammar(watson_items=[
                 "Review", "$ review", "$ find movies by rating",
                 "$ look up movies by rating", "$ highest rating",
                 "$ highest rated", "$ best rating", "$ best rated",
                 "$ lowest rating", "$ lowest rated", "$ oscar winners",
                 "$ best movie", "$ best movies"
             ]),
                   children=[
                       GreetingAction.reset(),
                       SmallTalkAction.set_to_zero(),
                       Goto(ref="output_2469539")
                   ]),
             Input(Grammar(["Movie theaters", "$ movie theaters"]),
                   children=[Goto(ref="output_2503320")]),
             Input(Grammar(
                 watson_items=["trailer", "$ trailer", "$ trailers"]),
                   children=[
                       GreetingAction.reset(),
                       SmallTalkAction.set_to_zero(),
                       Goto(ref="output_2510290")
                   ])
         ])
コード例 #14
0
 def create():
     return Folder(
         label="CLOSING SEQUENCES",
         children=[
             Input(Grammar(watson_items=[
                 "I should be going", "$ should be going", "$ should go",
                 "$ need to go", "$ got to go", "$ gotta run", "$ gotta go",
                 "$ need to run", "$ need to leave", "$ have to leave",
                 "$ have to go", "$ gtg"
             ]),
                   children=[
                       Output(
                           _id="output_2449675",
                           prompt=GenericPrompt.ok(),
                           children=[
                               Goto(ref="output_did_find_what_looking_for")
                           ])
                   ]),
             Input(Grammar(watson_items=[
                 "Thanks for your help", "$ thank you for your help",
                 "$ thanks for your help"
             ]),
                   children=[
                       Output(
                           Prompt(items=["You are welcome."]),
                           children=[
                               Goto(ref="output_did_find_what_looking_for")
                           ])
                   ]),
             Input(Grammar(watson_items=["Goodbye"]),
                   children=[
                       If(elements=[
                           TerminalExchangeConditions.is_yes(),
                           Goto(ref="output_end_of_conversation")
                       ]),
                       If(elements=[
                           TerminalExchangeConditions.is_no(),
                           Goto(ref="output_2449675")
                       ])
                   ])
         ])
コード例 #15
0
 def create(self):
     from dialog.elements import Entities as EntitiesElement
     return EntitiesElement([
         Entity(
             "DYNAMIC_DATA",
             [Value("DataCapture", "DataCapture", Grammar(items=["*"]))]),
         Entity("STYLE", [
             Value("high heels", "high heels",
                   Grammar(items=["high heels", "high-heels"])),
             Value("boots", "boots", Grammar(items=["boots", "boot"]))
         ]),
         Entity("COLOR", [
             Value("red", "red", Grammar(items=["red"])),
             Value("white", "white", Grammar(items=["white"])),
             Value("black", "black", Grammar(items=["black"]))
         ]),
         Entity("DINING", [])
         # TODO
         #         <entity name="DINING">
         #     <value name="restaurants" value="restaurants">
         #         <concept ref="concept_2456113"/>
         #     </value>
         #     <value name="bars" value="bars"/>
         # </entity>
     ])
コード例 #16
0
 def create():
     return Input(
         _id=RemoveColorInput.__id(),
         grammar=Grammar(watson_items=[
             "Remove genre", "$ remove (COLOR)={Color_Preference}",
             "$ cancel (COLOR)={Color_Preference}", "$ remove color",
             "$ cancel color", "$ any color", "$ all color"
         ]),
         children=[
             CurrentIndexAction.set_to_zero(),
             PageAction.set_to_new(),
             ColorPreferenceAction.set_to_blank(),
             Goto(ref="output_ok_do_search")
         ])
コード例 #17
0
    def test_regular(self):
        actual = Target(Mock(),
                        children=[
                            Grammar(watson_items=[Mock()]),
                            Action(var_name="var_name_value",
                                   operator="operator_value"),
                            Goto()
                        ])

        folder = Folder(children=[actual])
        dialog = Mock()
        folder._set_dialog(dialog)

        self.assertEqual(dialog, actual.children[0].dialog)
        self.assertEqual(dialog, actual.children[1].dialog)
        self.assertEqual(dialog, actual.children[2].dialog)
コード例 #18
0
 def create():
     return Input(
         grammar=Grammar(
             watson_items=[
                 "all items",
                 "$ all items",
                 "$ all results"
             ]
         ),
         children=[
             CurrentIndexAction.set_to_zero(),
             PageAction.set_to_new(),
             StylePreferenceAction.set_to_blank(),
             ColorPreferenceAction.set_to_blank(),
             Goto(ref="output_ok_do_search")
         ]
     )
コード例 #19
0
 def create():
     return Input(
         Grammar(watson_items=[
             "Details", "$ details", "$ detail", "$ movie info",
             "$ movie information"
         ]),
         children=[
             GreetingAction.reset(),
             SmallTalkAction.set_to_zero(),
             Output(Prompt(items=[
                 "After searching for movies, you can click on a particular movie result to see <i>details</i>, such as rating, summary and trailer.",
             ]),
                    children=[
                        GetUserInput(children=[
                            Input(GenericGrammar.ok(),
                                  children=[HowCanHelpYouOutput.goto()]),
                            PreliminarySequencesSearch.goto()
                        ])
                    ])
         ])
コード例 #20
0
 def create():
     return Input(
         Grammar(
             watson_items=[
                 "Remove rating",
                 "$ remove (STYLE)={Style_Preference}",
                 "$ cancel (STYLE)={Style_Preference}",
                 "$ remove style",
                 "$ cancel style",
                 "$ all styles",
                 "$ all style",
                 "$ any styles",
                 "$ any style"
             ]
         ),
         children=[
             CurrentIndexAction.set_to_zero(),
             PageAction.set_to_new(),
             StylePreferenceAction.set_to_blank(),
             Goto(ref="output_ok_do_search")
         ]
     )
コード例 #21
0
 def ok():
     return Grammar(watson_items=["okay", "ok"])
コード例 #22
0
    def create():
        return Folder(
            label="Main",
            children=[
                Output(
                    prompt=GenericPrompt.what_is_your_name(),
                    children=[
                        GetUserInput(
                            children=[
                                Input(
                                    Grammar(
                                        watson_items=[
                                            "Movies",
                                            "$ (Color)={Color_Preference}",
                                            "$ (Style)={Style_Preference}",
                                            "$ movies",
                                            "$ want to see something",
                                            "$ planning to go see",
                                            "$ planning to go to the",
                                            "$ going out to see",
                                            "$ planning to see",
                                            "$ want to go see",
                                            "$ thinking of seeing",
                                            "$ thinking we want to see",
                                            "$ what do you recommend",
                                            "$ can you recommend something",
                                            "$ what are your recommendations"
                                        ]
                                    ),
                                    children=[
                                        ColorPreferenceAction.set_to_value(),
                                        # CertificationPreferenceAction.set_to_value(),
                                        StylePreferenceAction.set_to_value(),
                                        TopicAction.set_to_shoes(),
                                        PreliminarySequencesSearch.goto()
                                    ]
                                ),
                                Input(
                                    Grammar(
                                        watson_items=[
                                            "Movie-related",
                                            "$ (OTHER_MOVIE)={Topic}",
                                            "$ (BY_OTHER_MOVIE)={Topic}",
                                            "$ showtimes",
                                            "$ theaters",
                                            "$ fandango",
                                            "$ reviews",
                                            "$ review",
                                            "$ critiques",
                                            "$ critique",
                                            "$ old movies",
                                            "$ classic movies",
                                            "$ oldies",
                                            "$ classics",
                                            "$ trailers",
                                            "$ reviews",
                                            "$ (DINING)={Topic}",
                                            "$ (WEATHER)={Topic}",
                                            "$ (TRAFFIC)={Topic}"
                                        ]
                                    ),
                                    children=[PreliminarySequencesSearch.goto()]
                                ),
                                Input(
                                    grammar=FeelingGrammar.create_preliminaries(),
                                    children=[

                                        PreliminarySequencesSearch.goto()
                                    ]
                                ),
                                Input(
                                    Grammar(
                                        watson_items=[
                                            "Why do you need to know?",
                                            "$ why",
                                            "$ need to know",
                                            "$ use it",
                                            "$ do with it"
                                        ]
                                    ),
                                    children=[
                                        Output(
                                            prompt=Prompt(
                                                items=["Just trying to be friendly."]
                                            ),
                                            children=[StartSearch.goto()]
                                        )
                                    ]
                                ),
                                Input(
                                    Grammar(
                                        watson_items=[
                                            "I don't want to give it!",
                                            "$ don't want",
                                            "$ no",
                                            "$ refuse",
                                            "$ none of your business"
                                        ]
                                    ),
                                    children=[
                                        Output(
                                            Prompt(items=["That's fine."]),
                                            children=[StartSearch.goto()]
                                        )
                                    ]
                                ),
                                Input(
                                    ProfileGrammar.create_my_name_is_dynamic_data(),
                                    children=[
                                        UserNameAction.set_to_source(),
                                        Output(
                                            prompt=Prompt(items=["Hi {User_Name}!"]),
                                            children=[StartSearch.goto()]
                                        )
                                    ],
                                    _id="input_user_knownas_name"
                                )
                            ],
                            _id="getUserInput_what_is_your_name"
                        ),
                        StartSearch.create(),
                        HowCanHelpYouOutput.create()
                    ],
                    _id="output_what_is_name"
                )
            ]
        )
コード例 #23
0
 def create_yes_goodbye():
     return Grammar(watson_items=[
         "Goodbye", "bye bye", "bye now", "bye", "later", "laters",
         "see you later", "see you", "see ya later", "see ya", "cya",
         "au revoir", "good night", "good day"
     ])
コード例 #24
0
 def yes_okay(wildcard=True):
     items = ["Yes", "Yes.", "Okay", "Ok"]
     if wildcard:
         items.append("$ yes")
     return Grammar(watson_items=items)
コード例 #25
0
 def create_no_full():
     return Grammar(watson_items=[
         "no", "n", "nope", "no way", "not really", "nah", "no thanks",
         "no thank you"
     ])
コード例 #26
0
 def create_haha():
     return Grammar(
         watson_items=["haha", "ha", "hehe", "lol", "rofl", "lmao"])
コード例 #27
0
 def create_you():
     return Grammar(watson_items=["you", "u"])
コード例 #28
0
 def no():
     return Grammar(watson_items=["No"])
コード例 #29
0
 def yes():
     return Grammar(watson_items=["Yes", "Yes.", "$ yes"])
コード例 #30
0
 def create_no_preference():
     return Grammar(watson_items=[
         "No", "$ no", "$ no preference", "$ don't care", "$ don't know",
         "$ none", "$ all", "$ anything", "$ any", "$ whatever",
         "$ nothing specific", "$ don't have a preference"
     ])