コード例 #1
0
    def test_regular(self):
        actual = Target(
            Prompt(items=[Mock()]),
            children=[Action("var_name_value", "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)
コード例 #2
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)
コード例 #3
0
 def create():
     return Folder(
         label="PRELIMINARY SEQUENCES",
         _id=PreliminarySequencesFolder._id(),
         children=[
             GreetingAction.reset(),
             SmallTalkAction.set_to_zero(),
             Input(
                 Grammar(watson_items=[
                     "Do you know", "$ do you know", "$ can you",
                     "$ do you have information", "$ can I",
                     "$ can you tell", "$ what kind of",
                     "$ what else do you know"
                 ]),
                 children=[
                     GreetingAction.reset(),
                     SmallTalkAction.set_to_zero(),
                     Input(
                         Grammar(watson_items=[
                             "out-of-scope movie topics",
                             "$ (OTHER_MOVIE)={Topic}"
                         ]),
                         children=[
                             TopicAction.set_to_value(),
                             Input(Grammar(watson_items=["what", "$ what"]),
                                   children=[
                                       Goto(ref="output_no_topic_lookup")
                                   ]),
                             Output(
                                 Prompt(items=["No."]),
                                 children=[
                                     Output(
                                         _id="output_no_topic_lookup",
                                         prompt=Prompt(items=[
                                             "I'm afraid I can't look up movies by {Topic}, only by Genre or MPAA Rating."
                                         ]),
                                         children=[
                                             GetUserInput(children=[
                                                 Input(
                                                     GenericGrammar.ok(),
                                                     children=[
                                                         HowCanHelpYouOutput
                                                         .goto()
                                                     ]),
                                                 PreliminarySequencesSearch.
                                                 goto()
                                             ])
                                         ])
                                 ])
                         ]),
                     Input(
                         Grammar(watson_items=[
                             "by out-of-scope movie topics",
                             "$ (BY_OTHER_MOVIE)={Topic}"
                         ]),
                         children=[
                             TopicAction.set_to_value(),
                             Input(
                                 Grammar(watson_items=["what", "$ what"]),
                                 children=[Goto(ref="output_2503370")]),
                             Output(
                                 Prompt(items=["No."]),
                                 children=[
                                     Output(
                                         _id="output_2503370",
                                         prompt=Prompt(items=[
                                             "I'm afraid I can't look up {Topic}, only Current and Upcoming movies by Genre or MPAA Rating.",
                                         ]),
                                         children=[
                                             GetUserInput(children=[
                                                 Input(Grammar(
                                                     watson_items=["Okay."
                                                                   ]),
                                                       children=[
                                                           HowCanHelpYouOutput
                                                           .goto()
                                                       ]),
                                                 PreliminarySequencesSearch.
                                                 goto()
                                             ])
                                         ])
                                 ])
                         ]),
                     Input(
                         Grammar(watson_items=[
                             "unsupported genres",
                             "$ (UNSUPPORTED_GENRES)={Topic}"
                         ]),
                         children=[
                             TopicAction.set_to_value(),
                             Input(
                                 grammar=Grammar(
                                     watson_items=["what", "$ what"]),
                                 children=[Goto(ref="output_2510164")]),
                             Output(
                                 Prompt(items=["No."]),
                                 children=[
                                     Output(
                                         _id="output_2510164",
                                         prompt=Prompt(items=[
                                             "I'm afraid {Topic} isn't a movie genre I know. Please try another one."
                                         ]),
                                         children=[
                                             GetUserInput(children=[
                                                 Input(grammar=Grammar(
                                                     watson_items=["Okay."
                                                                   ]),
                                                       children=[
                                                           HowCanHelpYouOutput
                                                           .goto()
                                                       ]),
                                                 PreliminarySequencesSearch.
                                                 goto()
                                             ])
                                         ])
                                 ])
                         ]),
                     # {
                     #     (0, "grammar"): {
                     #         "item": [
                     #             "theaters",
                     #             "$ theaters",
                     #             "$ fandango"
                     #         ]
                     #     },
                     #     (1, "input"): {
                     #         (0, "grammar"): {
                     #             "item": [
                     #                 "what",
                     #                 "$ what"
                     #             ]
                     #         },
                     #         (1, "goto"): {
                     #             "@ref": "output_2503320"
                     #         }
                     #     },
                     #     (2, "output"): {
                     #         (0, "prompt"): {
                     #             "item": "No."
                     #         },
                     #         (1, "output"): {
                     #             "@id": "output_2503320",
                     #             (0, "prompt"): {
                     #                 "item": "I'm afraid I cannot look up theaters myself, but I can give you a link to Fandango.com where you can buy tickets in your ZIP code. ",
                     #                 "@selectionType": "RANDOM"
                     #             },
                     #             (1, "getUserInput"): {
                     #                 (0, "input"): {
                     #                     (0, "grammar"): GenericGrammar.ok(),
                     #                     (1, "goto"): HowCanHelpYouOutput.goto()
                     #                 },
                     #                 (1, "goto"): PreliminarySequencesSearch.goto()
                     #             }
                     #         }
                     #     }
                     # },
                     Input(Grammar(
                         watson_items=["$ (STYLE)={Style_Preference}"]),
                           children=[
                               StylePreferenceAction.set_to_value(),
                               Goto(ref="search_2414740")
                           ]),
                     Input(
                         Grammar(watson_items=["genres", "$ genres"]),
                         children=[
                             Output(Prompt(items=[
                                 "Action, adventure, animated, comedy, crime, documentary, drama, family, fantasy, foreign, historical, horror, music, mystery, romance, science fiction, TV movie, thriller, war movies and western.  <br> <br>"
                             ]),
                                    children=[
                                        GetUserInput(children=[
                                            Input(GenericGrammar.ok(),
                                                  children=[
                                                      HowCanHelpYouOutput.
                                                      goto()
                                                  ]),
                                            PreliminarySequencesSearch.goto(
                                            )
                                        ])
                                    ])
                         ]),
                     # {
                     #     (0, "grammar"): {
                     #         "item": [
                     #             "old movies",
                     #             "$ old movies",
                     #             "$ classic movies",
                     #             "$ oldies",
                     #             "$ classics"
                     #         ]
                     #     },
                     #     (1, "input"): {
                     #         (0, "grammar"): {
                     #             "item": [
                     #                 "what",
                     #                 "$ what"
                     #             ]
                     #         },
                     #         (1, "goto"): {
                     #             "@ref": "output_2503380"
                     #         }
                     #     },
                     #     (2, "output"): {
                     #         (0, "prompt"): {
                     #             "item": "No."
                     #         },
                     #         (1, "output"): {
                     #             "@id": "output_2503380",
                     #             (0, "prompt"): {
                     #                 "item": "I'm afraid I cannot look up Old Movies, only Current and Upcoming.",
                     #                 "@selectionType": "RANDOM"
                     #             },
                     #             (1, "getUserInput"): {
                     #                 (0, "input"): {
                     #                     (0, "grammar"): GenericGrammar.ok(),
                     #                     (1, "goto"): HowCanHelpYouOutput.goto()
                     #                 },
                     #                 (1, "goto"): PreliminarySequencesSearch.goto()
                     #             }
                     #         }
                     #     }
                     # },
                     Input(
                         Grammar(watson_items=["shoes", "$ shoes"]),
                         children=[
                             TopicAction.set_to_shoes(),
                             Input(
                                 Grammar(watson_items=["what", "$ what"]),
                                 children=[
                                     Goto(ref="output_what_jemboo_knows")
                                 ]),
                             Output(
                                 prompt=Prompt(items=["Yes."]),
                                 children=[
                                     Output(
                                         _id="output_what_jemboo_knows",
                                         prompt=Prompt(items=[
                                             "I can look up current and upcoming movies by Genre or MPAA Rating and show you trailers for them. But I'm afraid I cannot search by number of stars or by movie titles or actor and director names at this time.",
                                         ]),
                                         children=[
                                             GetUserInput(children=[
                                                 Input(
                                                     GenericGrammar.ok(),
                                                     children=[
                                                         HowCanHelpYouOutput
                                                         .goto()
                                                     ]),
                                                 PreliminarySequencesSearch.
                                                 goto()
                                             ])
                                         ])
                                 ])
                         ]),
                     # {
                     #     (0, "grammar"): {
                     #         "item": [
                     #             "trailer",
                     #             "$ trailer",
                     #             "$ trailers"
                     #         ]
                     #     },
                     #     (1, "input"): {
                     #         (0, "grammar"): {
                     #             "item": [
                     #                 "what",
                     #                 "$ what"
                     #             ]
                     #         },
                     #         (1, "goto"): {
                     #             "@ref": "output_2510290"
                     #         }
                     #     },
                     #     (2, "output"): {
                     #         (0, "prompt"): {
                     #             "item": "Yes."
                     #         },
                     #         (1, "output"): {
                     #             "@id": "output_2510290",
                     #             (0, "prompt"): {
                     #                 "item": "After searching for movies, you can click on a particular movie result to watch its <i>trailer</i>, or video preview.",
                     #                 "@selectionType": "RANDOM"
                     #             },
                     #             (1, "getUserInput"): {
                     #                 (0, "input"): {
                     #                     (0, "grammar"): GenericGrammar.ok(),
                     #                     (1, "goto"): HowCanHelpYouOutput.goto()
                     #                 },
                     #                 (1, "goto"): PreliminarySequencesSearch.goto()
                     #             }
                     #         }
                     #     }
                     # },
                     Input(
                         Grammar(watson_items=[
                             "out-of-scope topics", "$ (DINING)={Topic}",
                             "$ (WEATHER)={Topic}", "$ (TRAFFIC)={Topic}"
                         ]),
                         children=[
                             TopicAction.set_to_value(),
                             OutOfScopeCountAction.increment(),
                             If(elements=[
                                 OutOfScopeCountConditions.is_greater_then(
                                     "2"),
                                 Output(Prompt(items=[
                                     "I'm sorry I don't know about that. Can I look up some shoes for you?"
                                 ]),
                                        children=[
                                            GetUserInput(children=[
                                                Input(
                                                    GenericGrammar.yes(),
                                                    children=[
                                                        StylePreferenceProfileCheck
                                                        .goto()
                                                    ]),
                                                Input(
                                                    GenericGrammar.no(),
                                                    children=[
                                                        Action(
                                                            var_name=
                                                            "Out-of-Scope_Count",
                                                            operator=
                                                            "SET_TO",
                                                            text="0"),
                                                        Output(prompt=
                                                               GenericPrompt
                                                               .ok_fine())
                                                    ]),
                                                Input(
                                                    GenericGrammar.ok(),
                                                    children=[
                                                        StylePreferenceProfileCheck
                                                        .goto()
                                                    ]),
                                                PreliminarySequencesSearch.
                                                goto()
                                            ])
                                        ])
                             ]),
                             Input(Grammar(watson_items=["what", "$ what"]),
                                   children=[Goto(ref="output_2497989")]),
                             Output(
                                 Prompt(items=["No."]),
                                 children=[
                                     Output(
                                         _id="output_2497989",
                                         prompt=Prompt(items=[
                                             "I'm afraid I don't know much about {Topic}. Just movies."
                                         ]),
                                         children=[
                                             GetUserInput(children=[
                                                 Input(Grammar(
                                                     watson_items=["Okay."
                                                                   ]),
                                                       children=[
                                                           HowCanHelpYouOutput
                                                           .goto()
                                                       ]),
                                                 PreliminarySequencesSearch.
                                                 goto()
                                             ])
                                         ])
                                 ])
                         ]),
                     Goto(ref="output_what_jemboo_knows")
                 ])
         ])
コード例 #4
0
 def set_to_value():
     return Action(var_name="Color_Preference",
                   operator="SET_TO",
                   text="{Color_Preference.value:main}")
コード例 #5
0
 def increment():
     return Action(var_name=NAME_OUT_OF_SCOPE_COUNT,
                   operator="INCREMENT_BY",
                   text="1")
コード例 #6
0
 def create_set_to_upcoming():
     return Action(var_name="Recency_Preference",
                   operator="SET_TO",
                   text="Upcoming")
コード例 #7
0
 def set_to_zero():
     return Action(var_name=NAME_CURRENT_INDEX, operator="SET_TO", text="0")
コード例 #8
0
 def set_to_previous():
     return Action(var_name=NAME_PAGE, operator="SET_TO", text="previous")
コード例 #9
0
 def create_increment():
     return Action(var_name="Small_Talk_Count",
                   operator="INCREMENT_BY",
                   text="1")
コード例 #10
0
 def set_to_yes():
     return Action(var_name="Terminal_Exchange", operator="SET_TO_YES")
コード例 #11
0
 def set_to_no():
     return Action(var_name="Terminal_Exchange", operator="SET_TO_NO")
コード例 #12
0
 def set_to_yes():
     return Action(var_name=NAME_SEARCH_NOW, operator="SET_TO_YES")
コード例 #13
0
 def set_to_no():
     return Action(var_name=NAME_SEARCH_NOW, operator="SET_TO_NO")
コード例 #14
0
 def create_increment():
     return Action(var_name="Greeting_Count",
                   operator="INCREMENT_BY",
                   text="1")
コード例 #15
0
 def create():
     # Folder
     return Folder(
         label="SYSTEM INITIATED SEQUENCES",
         children=[
             Output(
                 _id=SystemInitiatedSequences.__id(),
                 prompt=Prompt(
                     items=["Is there anything else I can help you with?"]),
                 children=[
                     PageAction.set_to_new(),
                     Action(var_name="Current_Index",
                            operator="SET_TO",
                            text="0"),
                     ColorPreferenceAction.set_to_blank(),
                     # RecencyPreferenceAction.set_to_blank(),
                     StylePreferenceAction.set_to_blank(),
                     Action(var_name="Search_Now", operator="SET_TO_NO"),
                     Action(var_name="Terminal_Exchange",
                            operator="SET_TO_BLANK"),
                     Action(var_name="Topic", operator="SET_TO_BLANK"),
                     Action(var_name="ZIP_Code_Preference",
                            operator="SET_TO_BLANK"),
                     Action(var_name="Display_Trailer",
                            operator="SET_TO_NO"),
                     Action(var_name="Selected_Movie",
                            operator="SET_TO_BLANK"),
                     Action(var_name="Display_Movie_Details",
                            operator="SET_TO_NO"),
                     Action(var_name="Display_Reviews",
                            operator="SET_TO_NO"),
                     Action(var_name="Popularity_Score",
                            operator="SET_TO",
                            text="0.5"),
                     GetUserInput(children=[
                         Input(GenericGrammar.yes(),
                               children=[HowCanHelpYouOutput.goto()]),
                         Input(
                             GenericGrammar.no(),
                             children=[
                                 Output(
                                     prompt=GenericPrompt.ok(),
                                     children=[
                                         Goto(
                                             ref=
                                             "output_did_find_what_looking_for"
                                         )
                                     ])
                             ]),
                         PreliminarySequencesSearch.goto()
                     ])
                 ]),
             Output(
                 _id="output_did_find_what_looking_for",
                 prompt=Prompt(items=[
                     "Did you find what you were looking for, {User_Name}?"
                 ]),
                 children=[
                     GetUserInput(children=[
                         Input(
                             GenericGrammar().yes(),
                             children=[
                                 RequestSuccessAction.set_to_yes(),
                                 Output(
                                     prompt=Prompt(items=["Great!"]),
                                     children=[
                                         Output(
                                             _id="output_goodbye",
                                             prompt=Prompt(items=[
                                                 "Goodbye.<br> <br>"
                                             ]),
                                             children=[
                                                 TerminalExchangeAction.
                                                 set_to_yes(),
                                                 GreetingAction.reset(),
                                                 GetUserInput(children=[
                                                     Input(
                                                         Grammar(watson_items
                                                                 =[
                                                                     "Goodbye",
                                                                     "$ goodbye"
                                                                 ]),
                                                         children
                                                         =[
                                                             Output(
                                                                 _id=
                                                                 "output_end_of_conversation",
                                                                 prompt=
                                                                 Prompt(
                                                                     items
                                                                     ="&lt;i&gt;Say anything to continue.&lt;/i&gt;"
                                                                 ),
                                                                 children=[
                                                                     GetUserInput(children=[
                                                                         Output(
                                                                             _id
                                                                             ="output_welcome_back",
                                                                             prompt
                                                                             =Prompt(
                                                                                 items
                                                                                 =[
                                                                                     "Welcome back!"
                                                                                 ]
                                                                             ),
                                                                             children
                                                                             =[
                                                                                 HowCanHelpYouOutput
                                                                                 .
                                                                                 goto(
                                                                                 )
                                                                             ]
                                                                         )
                                                                     ])
                                                                 ]),
                                                         ]),
                                                     HowCanHelpYouOutput.
                                                     goto()
                                                 ])
                                             ])
                                     ])
                             ]),
                         Input(
                             GenericGrammar.no(),
                             children=[
                                 RequestSuccessAction.set_to_no(),
                                 Output(
                                     prompt=Prompt(
                                         items=[
                                             "Oh no. Do you want to try again?"
                                         ]),
                                     children=[
                                         GetUserInput(children=[
                                             Input(
                                                 GenericGrammar.no(),
                                                 children=
                                                 [
                                                     TerminalExchangeAction.
                                                     set_to_no(),
                                                     Output(
                                                         prompt
                                                         =GenericPrompt.ok(
                                                         ),
                                                         children=[
                                                             Goto(ref=
                                                                  "output_goodbye"
                                                                  )
                                                         ])
                                                 ]),
                                             Input(
                                                 GenericGrammar.yes(),
                                                 children=[
                                                     Output(prompt=Prompt(
                                                         items=[
                                                             "Okay. What can I do for you?"
                                                         ]),
                                                            children=[
                                                                Goto(
                                                                    "getUserInput_how_can_i_help_you"
                                                                )
                                                            ])
                                                 ])
                                         ])
                                     ])
                             ]),
                         PreliminarySequencesSearch.goto()
                     ])
                 ]),
             Output(
                 _id="output_too_much_small_talk",
                 prompt=Prompt(items=[
                     "This is fun, but wouldn't you like to look up some movies?"
                 ]),
                 children=[
                     GetUserInput(children=[
                         Input(
                             GenericGrammar.yes(),
                             children=[StylePreferenceProfileCheck.goto()]),
                         Input(GenericGrammar.no(),
                               children=[
                                   SmallTalkAction.set_to_zero(),
                                   Output(GenericPrompt.ok_fine())
                               ]),
                         Input(
                             GenericGrammar.ok(),
                             children=[StylePreferenceProfileCheck.goto()]),
                         PreliminarySequencesSearch.goto()
                     ])
                 ])
         ])
コード例 #16
0
 def set_to_no():
     return Action(var_name="Request_Success", operator="SET_TO_NO")
コード例 #17
0
 def set_to_zero():
     return Action(var_name="Small_Talk_Count", operator="SET_TO", text="0")
コード例 #18
0
 def set_to_blank():
     return Action(var_name="Terminal_Exchange", operator="SET_TO_BLANK")
コード例 #19
0
 def set_to_repeat():
     return Action(var_name=NAME_PAGE, operator="SET_TO", text="repeat")
コード例 #20
0
 def set_to_blank():
     return Action(var_name="Topic", operator="SET_TO_BLANK")
コード例 #21
0
 def set_to_next():
     return Action(var_name=NAME_PAGE, operator="SET_TO", text="next")
コード例 #22
0
 def set_to_value():
     return Action(var_name="Topic",
                   operator="SET_TO",
                   text="{Topic.value:main}")
コード例 #23
0
 def create_set_to_value():
     return Action(var_name="Recency_Preference",
                   operator="SET_TO",
                   text="{Recency_Preference.value:main}")
コード例 #24
0
 def set_to_shoes():
     return Action(var_name="Topic", operator="SET_TO", text="shoes")
コード例 #25
0
 def set_to_current():
     return Action(var_name="Recency_Preference",
                   operator="SET_TO",
                   text="Current")
コード例 #26
0
 def set_to_blank():
     return Action(var_name="Request_Success", operator="SET_TO_BLANK")
コード例 #27
0
 def set_to_blank():
     return Action(var_name="Color_Preference", operator="SET_TO_BLANK")
コード例 #28
0
 def set_to_source():
     return Action(var_name=NAME_USER_NAME,
                   operator="SET_TO",
                   text="{User_Name.source}")
コード例 #29
0
 def reset():
     return Action(var_name="Greeting_Count", operator="SET_TO", text="0")
コード例 #30
0
 def set_to_yes():
     return Action(var_name="Request_Success", operator="SET_TO_YES")