Normalize contextual travel research #370
@@ -172,6 +172,10 @@ func TestTravelRouteWithKnownOriginDoesNotAskForTicketDate(t *testing.T) {
|
||||
if got := TravelSearchClarification("как можно добраться до Сочи?", history); got != "" {
|
||||
t.Fatalf("general route was incorrectly reduced to ticket clarification: %q", got)
|
||||
}
|
||||
got := TravelResearchQuery("как можно добраться до Сочи?", history, time.Time{})
|
||||
if got != "способы добраться из Москве в Сочи: самолет поезд автобус автомобиль" {
|
||||
t.Fatalf("general route query lost known route context: %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInterpretUtteranceDirectiveRecordsOutcomeWithoutExecution(t *testing.T) {
|
||||
|
||||
@@ -38,7 +38,12 @@ func TravelResearchQuery(message string, history []interaction.HumanUtterance, n
|
||||
}
|
||||
query += " расстояние по прямой и по дороге"
|
||||
} else if containsStemInTokens(tokens, "добрат", "маршрут") {
|
||||
if origin := travelContextOrigin(history); origin != "" && !containsStemInTokens(tokens, "из", "откуда", "от") {
|
||||
origin := travelContextOrigin(history)
|
||||
destination := travelContextDestinationFromTokens(tokens)
|
||||
if origin != "" && destination != "" {
|
||||
return "способы добраться из " + origin + " в " + destination + ": самолет поезд автобус автомобиль"
|
||||
}
|
||||
if origin != "" && !containsStemInTokens(tokens, "из", "откуда", "от") {
|
||||
query += " отправление из " + origin
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user