示例#1
0
 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
示例#2
0
 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]"
示例#3
0
 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?"
示例#4
0
 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."
示例#5
0
 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?"
示例#6
0
 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?"
示例#7
0
 def information(self, data, conversation):
     parameters = ConversationData(conversation.conversation_params)
     parameters.subject = data.get('subject')
     conversation.conversation_params = parameters.to_json()
     "[De geleverde informatie]"
示例#8
0
 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:"
示例#9
0
 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?"
示例#10
0
 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"
示例#11
0
 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?"
示例#12
0
 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...]"