# part 3 end END = 241 TRAP = 242 # ontology ontology = { "ontology": { "non_home_locations": [ "work", "office", "lab", "class", "lecture", "meeting", "travel", "school" ] } } # start knowledge = KnowledgeBase() knowledge.load_json(ontology) df = DialogueFlow(State.START, initial_speaker=DialogueFlow.Speaker.SYSTEM, kb=knowledge) # desktop or laptop df.add_system_transition( State.START, State.NAME_Q, '"hello, I am Emily, a virtual chatbot, what is your name? (Please simply type your name.)"' ) df.add_user_transition(State.NAME_Q, State.NAME_R, '[$name=/.*/]') df.add_system_transition(State.NAME_R, State.COM_Q, '[!"Hi"$name", do you have a computer?"]') df.add_user_transition(State.COM_Q, State.COM_NO, '[{No,no,not,nah,Nah,N,n}]') df.add_system_transition(
"funny", "humorous", "clever", "witty", "hilarious", "joker", "jokester" ], "outgoing": ["outgoing", "extraverted", "sociable", "social", "friendly", "warm"], "shy": ["shy", "intraverted", "guarded", "loner"], "polite": ["polite", "manners", "decent"], "conceited": [ "conceited", "overconfident", "arrogant", "full of", "narcissistic", "egotistic", "egotistical", "selfish" ], "beautiful": ["gorgeous", "pretty", "hot", "sexy"] } } kb = KnowledgeBase() kb.load_json(kb_dict) df = DialogueFlow(initial_state="root", kb=kb) root = 'root' end = 'end' df.add_state(root, error_successor=root, memory=0) df.add_state(end, error_successor=end) df.add_system_transition(root, end, 'I have no nonrepetitive options', score=0) # S: Who do you live with? root = 'root' df.add_state('opening live with', error_successor=root) df.add_system_transition(root, 'opening live with', '[!#GATE() "So, who do you live with?"]')