Avoid inheriting stale travel goals #315
@@ -80,6 +80,9 @@ func TestTravelSearchClarification(t *testing.T) {
|
||||
if got := TravelSearchClarification("а куда летим?", history); got == "" {
|
||||
t.Fatal("follow-up must remain attached to the travel goal")
|
||||
}
|
||||
if got := TravelSearchClarification("какая погода в Сочи?", history); got != "" {
|
||||
t.Fatalf("unrelated question must not inherit travel goal, got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestInterpretUtteranceDirectiveRecordsOutcomeWithoutExecution(t *testing.T) {
|
||||
|
||||
@@ -30,7 +30,7 @@ func StripAssistantVocative(message string) string {
|
||||
func TravelSearchClarification(message string, history []interaction.HumanUtterance) string {
|
||||
current := semanticTokens(StripAssistantVocative(message))
|
||||
travel := travelCue(current)
|
||||
if !travel {
|
||||
if !travel && travelFollowUpCue(current) {
|
||||
for index := len(history) - 1; index >= 0; index-- {
|
||||
if travelCue(semanticTokens(history[index].Content)) {
|
||||
travel = true
|
||||
@@ -62,6 +62,10 @@ func travelCue(tokens []string) bool {
|
||||
return containsStemInTokens(tokens, "билет", "рейс", "поезд", "автобус", "перелет", "перелёт")
|
||||
}
|
||||
|
||||
func travelFollowUpCue(tokens []string) bool {
|
||||
return containsStemInTokens(tokens, "куда", "откуда", "маршрут", "летим", "дата", "число")
|
||||
}
|
||||
|
||||
func hasDigit(value string) bool {
|
||||
for _, runeValue := range value {
|
||||
if runeValue >= '0' && runeValue <= '9' {
|
||||
|
||||
Reference in New Issue
Block a user