예제 #1
0
            "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?"]')
    # 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(
예제 #3
0
    ERR = 4
    REPTILE = 5
    AMPHIBIAN = 6


################################

################################
# Modify ont_dict for Quiz2 Task 3
################################

ont_dict = {"ontology": {"amphibian": ["frog", "salamander"]}}

################################

knowledge = KnowledgeBase()
knowledge.load_json(ont_dict)
df = DialogueFlow(State.START,
                  initial_speaker=DialogueFlow.Speaker.SYSTEM,
                  kb=knowledge)

df.add_system_transition(State.START, State.PROMPT, '"Enter an animal"')
df.add_user_transition(State.PROMPT, State.MAMMAL, "[$animal={cat,dog}]")
df.add_user_transition(State.PROMPT, State.BIRD,
                       "[$animal={parrot,dove,crow}]")
df.add_user_transition(State.PROMPT, State.REPTILE,
                       "[$animal={snake,lizard,turtle,alligator}]")
df.add_user_transition(State.PROMPT, State.AMPHIBIAN,
                       "[$animal=#ONT(amphibian)]")
df.add_system_transition(State.MAMMAL, State.PROMPT,
                         '[! $animal " is a mammal, enter another animal"]')
예제 #4
0
                str += "I don't see much contribution he is making to the team especially with scoring. "
            elif (position == "C" or position == "PF" and REB <= 4):
                str += "He's not a good rebounder for his position. "
            elif (position == "PG" and AST <= 3):
                str += "He is not that great with his assists to make a contribution to the team. "
            else:
                str += "He doesn't have any specialty in points, rebounds, nor assists."
            str += "I just don't see how he would suddenly get better."
            if (player('2019-20').minutes_played /
                    player('2019-20').games_played < 12
                    or player('2019-20').minutes_played == None):
                str += "Besides, who is this player anyways because I've never heard of him."
            return str


knowledge = KnowledgeBase()
knowledge.load_json_file("teams.json")
df = DialogueFlow(State.START,
                  initial_speaker=DialogueFlow.Speaker.SYSTEM,
                  kb=knowledge,
                  macros={
                      'news': news(),
                      'newsPlayer': newsPlayer(),
                      'newsTeam': newsTeam(),
                      'teamStats': teamStats(),
                      'playerRating': playerRating(),
                      'goodBadTrade': goodBadTrade(),
                      'tradeNews': tradeNews()
                  })

#########################
예제 #5
0
class indComp(Macro):
    def run(self, ngrams, vars, args):
        if 'industry' in vars:
            for key, value in industry_company.items():
                if key in vars['industry']:
                    return value

class posSkill(Macro):
    def run(self, ngrams, vars, args):
        if 'pos' in vars:
            for key, value in pos_skill.items():
                if key in vars['pos']:
                    return value

knowledge = KnowledgeBase()
knowledge.load_json(ind_pos)
knowledge.load_json(ind_comp)
df = DialogueFlow(State.S1, initial_speaker=DialogueFlow.Speaker.SYSTEM, kb=knowledge, macros={"placeInd": placeInd(),"indComp":indComp(),"posSkill":posSkill()})

df.add_system_transition(State.S1, State.U1, '"Where do you want to work?"')
df.add_user_transition(State.U1, State.S2a, '[$loc={new york,ny,la,los angeles,chicago,dallas,washington dc,dc,west,east,bay,san francisco,sf,houston,boston,bos,atl,atlanta,seattle,sea,san jose}]', score=1)
df.add_user_transition(State.U1, State.S2b, '[$loc={new york,ny,la,los angeles,chicago,dallas,washington dc,dc,west,east,bay,san francisco,sf,houston,boston,bos,atl,atlanta,seattle,sea,san jose}]')
df.add_user_transition(State.U1, State.S2c, '[$comp=#ONT(ontfinanc)]', score = 2)
df.add_user_transition(State.U1, State.S2d, '[$comp=#ONT(ontconsultin)]', score = 2)
df.add_user_transition(State.U1, State.S2e, '[$comp=#ONT(onttechnolog)]', score = 2)
df.add_user_transition(State.U1, State.S2f, '[$comp=#NER(org)]', score = 1)
df.add_user_transition(State.U1, State.S2g, '[{dont know,do not know,unsure,[not,{sure,certain,considered,consider,thought}],hard to say,no idea,uncertain,[!no {opinion,opinions,idea,ideas,thought,thoughts,knowledge}]}]')
df.set_error_successor(State.U1, error_successor=State.ERR1)

df.add_system_transition(State.S2a, State.U2a, '[!Sure"." $loc is a great place to work"!" There are a lot of #placeInd companies there"." What industry are you interested in"?"]')
예제 #6
0
    END = auto()
    ERR = auto()


VR_company = {
    "ontology": {
        "company": ["google", "htc", "samsung", "oculus"],
        "ontgoogle": ["cardboard", "google"],
        "onthtc": ["vive", "htc"],
        "ontsamsung": ["gear", "samsung"],
        "ontoculus": ["rift", "oculus"],
        "ontsony": ["morpheus", "vr", "sony", "playstation"]
    }
}

knowledge = KnowledgeBase()
knowledge.load_json(VR_company)
df = DialogueFlow(State.S0,
                  initial_speaker=DialogueFlow.Speaker.SYSTEM,
                  kb=knowledge)

#Initalize Yes, Yes+vr, and No for first question

df.add_system_transition(State.S0, State.U0,
                         r'[!Have you ever used Virtual Reality before"?"]')

#Yes+VR Company Answer
df.add_user_transition(State.U0, State.S2_google, "<$VR=#ONT(ontgoogle)>")
df.add_user_transition(State.U0, State.S2_htc, "<$VR=#ONT(onthtc)>")
df.add_user_transition(State.U0, State.S2_samsung, "<$VR=#ONT(ontsamsung)>")
df.add_user_transition(State.U0, State.S2_oculus, "<$VR=#ONT(ontoculus)>")
예제 #7
0
                "customer support",
                "credit card information",
                "wait",
                "waiting",
                "convenient"
            ],
             "ontreason_personal": ##personal reasons
            [
                "cook",
                "cooking",
                "lazy"
            ]
    }
}

knowledge = KnowledgeBase()
knowledge.load_json(foodapp_dict)
df = DialogueFlow(State.START,
                  initial_speaker=DialogueFlow.Speaker.SYSTEM,
                  kb=knowledge)

df.add_system_transition(State.START, State.PROMPT_0,
                         r'[!"Do you use any food apps?"]')
df.add_user_transition(
    State.PROMPT_0, State.TURN_0_yes,
    r'<$TURN_0_yes_response={[!#ONT(ontyes)],[!#ONT(ontdelivery)],[!#ONT(ontrating)],[!#ONT(onttype)]}>'
)

df.add_system_transition(
    State.TURN_0_yes, State.PROMPT_1A,
    '"Do you use it for food delivery or rating?"')  ##corner