HI @threxx
Da ich das Problem mit deutschen Trainings-Daten kenne, könnte ich dir auch auf Deutsch Fragen beantworten. Damit die anderen Foren-Nutzer folgen können, erkläre ich dir die Sache aber auf Englisch. Du kannst mich gern auch anderweitig kontaktieren.
First of all intents should be separated if they could be separated. Sometimes this might seem to be a bit penibel but makes things easier after a while. For your setup I would recommend (as a starting point):
# intent:location_next_lesson
- Where is my next lesson?
- Tell me the room of my next lesson
- Where do I have [biology](subject) next?
- In which room do I have [maths](subject)
# intent:time_next_lesson
- When do I have my next lesson?
- When does my next lesson start?
- When does [art](subject) start?
- When do I have [history](subject)
By defining those two intents you actually combined the questions for a general next lesson and a specific lesson but you did more: You told the algorithm that inside those training data, there are entities (your subjects) and you told it further how the sentences, embedding those entities, look like.
To avoid the necessity to add training samples for all entities, you could easily use a lookup table as described here:
Now you need a custom action that is able to get the information about the lessons and your timetable.
Assuming that you are doing this the first time, here is a little sample:
class TimetableLocation(Action):
def name(self):
# type: () -> Text
return "get_next_lesson_location"
def run(self, dispatcher, tracker, domain):
# type: (CollectingDispatcher, Tracker, Dict[Text, Any]) -> List[Dict[Text, Any]]
specific_subject = None
for subject in tracker.get_latest_entity_values('subject'):
specific_subject = subject
break
if specific_subject is not None:
location = <code for getting the next lesson for the specific subject>
message = 'Das Fach {} hast du das nächste Mal in Raum {}'.format(specific_subject, location)
else:
location = <code for getting the next lesson>
message = 'Du musst als nächstes in Raum {}'.format(location)
dispatcher.utter_message(message)
return []
A crucial point here is to use:
tracker.get_latest_entity_values('subject')
since this line allows you to check if the user did not only trigger the intent rather than to trigger the intent and add an entity. This is only a simple sample, I am sure there are other things to take care of. If your cases are growing in complexity, you might want to consider a FormAction.
If you now provide a proper story and enough training data, it will work the way you wanted and your other mentioned intents work accordingly.
Feel free to ask for help.
Regards