diff --git a/modules/interaction/domain/semantics_test.go b/modules/interaction/domain/semantics_test.go index da7bbfa..add22e4 100644 --- a/modules/interaction/domain/semantics_test.go +++ b/modules/interaction/domain/semantics_test.go @@ -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) { diff --git a/modules/interaction/domain/travel.go b/modules/interaction/domain/travel.go index 8e41179..763a60c 100644 --- a/modules/interaction/domain/travel.go +++ b/modules/interaction/domain/travel.go @@ -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 } }