python - chatbot: how to correctly determine intents? -
what usual techniques determine difference between following intents, example?
what current temperature? in case, straight-up response current temperature.
is current temperature 22 degrees? in case, appropriate response yes or no.
i building closed-domain chatbot (eg siri) , wondering if there techniques in python can read about.
i once got programming trying understand how bots work. little world. barely remember how did mine let's assume build chat based on events bot can read. basic way determine answer each event huge list of if elif stuff nested behaviours (ideally split methods).
def handleevent (message, user, date, font, whatever): if "current temperature" in message: send_text_to_chat("the temperature 22 degrees") elif "is current temperature" in message , "?" in message: specific_temp_asked(message) elif "potato" in message: # hundred of behaviours, , nested ones. if user == "apple": send_text_to_chat("hi apple!") else: send_text_to_chat("i potato bot") elif "who i?" in message: # example using event data send_text_to_chat("you " + user) else: send_text_to_chat("be more specific")
and have code each of specific situations this:
def specific_temp_asked(message): temperature = none split_message = message.split(" ") in split_message: try: int(i) temperature = break except: pass if not temperature == none: real_temperature = check_temp(somehow) if real_temperature == temperature: send_text_to_chat("yes") else: send_text_to_chat("nope")
final note: no means best way it, if learning i'll work done without being complicated, , improve code slowly.
Comments
Post a Comment