def parse(self, data, conversation): conversation_data = ConversationData(conversation.conversation_params) context = {'conversation': conversation} for key, value in conversation_data.__dict__.items(): context[key] = value intent = '_default' print("intent" + intent) if 'entities' in data: for key, value in data['entities'].items(): if type(value) is list: value = value[0] print(value) if key == 'intent': intent = value['value'] print(intent) else: context[key] = value['from'] if 'from' in value else value[ 'value'] print(context) print(intent) # todo: misschien hier na een paar keer menselijke help inroepen? result, context = getattr(self, intent)(context) or [ 'Ik kan je niet zo goed volgen, zou je me dit nog een keer kunnen vertellen?', context ] for key, value in context.items(): if key != 'conversation': setattr(conversation_data, key, value) conversation.conversation_params = conversation_data.to_json() conversation.save() print(result) return result
def price_information(self, data, conversation): parameters = ConversationData(conversation.conversation_params) parameters.start_time = data.get('start_time') parameters.end_time = data.get('end') parameters.subject = data.get('subject') parameters.duration = data.get('duration') conversation.conversation_params = parameters.to_json() return "De prijs is [price]"
def reserve_something(self, data, conversation): parameters = ConversationData(conversation.conversation_params) parameters.film_date = data.get('date') parameters.subject = data.get('subject') parameters.number_of_persons = data.get('number') conversation.conversation_params = parameters.to_json() return "Hoe zou u de kaartjes willen ontvangen?"
def reserve_restaurant(self, data, conversation): parameters = ConversationData(conversation.conversation_params) parameters.film_date = data.get('date') parameters.subject = data.get('subject') parameters.number_of_persons = data.get('number') conversation.conversation_params = parameters.to_json() return "Dat kan. De reservering is gedaan."
def recommend_movie(self, data, conversation): parameters = ConversationData(conversation.conversation_params) parameters.subject = data.get('subject') parameters.genre = data.get('genre') parameters.film_date = data.get('date') conversation.conversation_params = parameters.to_json() return "Wanneer zou je naar de film willen gaan?"
def find_something(self, data, conversation): parameters = ConversationData(conversation.conversation_params) parameters.film_date = data.get('date') parameters.subject = data.get('subject') conversation.conversation_params = parameters.to_json() return "Heeft u een tijdstip in gedachte?"
def information(self, data, conversation): parameters = ConversationData(conversation.conversation_params) parameters.subject = data.get('subject') conversation.conversation_params = parameters.to_json() "[De geleverde informatie]"
def recommend_book(self, data, conversation): parameters = ConversationData(conversation.conversation_params) parameters.book_author = data.get('author') parameters.genre = data.get('genre') conversation.conversation_params = parameters.to_json() return "Dat kan. Hier is het aanbod:"
def find_restaurant(self, data, conversation): parameters = ConversationData(conversation.conversation_params) parameters.number_of_persons = data.get('number') parameters.subject = data.get('subject') conversation.conversation_params = parameters.to_json() return "Wanneer bent u van plan te komen?"
def review(self, data, conversation): parameters = ConversationData(conversation.conversation_params) parameters.review_sentiment = data.get('sentiment') conversation.conversation_params = parameters.to_json() return "Bedankt voor uw feedback"
def find_parking(self, data, conversation): parameters = ConversationData(conversation.conversation_params) parameters.film_date = data.get('date') conversation.conversation_params = parameters.to_json() return "Hoelaat bent u van plan te komen?"
def recommend_something(self, data, conversation): parameters = ConversationData(conversation.conversation_params) parameters.genre = data.get('genre') parameters.subject = data.get('subject') conversation.conversation_params = parameters.to_json() return "Misschien dat deze films iets zijn? : [...show films...]"