@@ -278,6 +278,7 @@ func semanticScores(tokens []string, hasQuestionMark bool, explicitCorrection bo
|
|||||||
}
|
}
|
||||||
questionWords := map[string]struct{}{"кто": {}, "что": {}, "как": {}, "почему": {}, "зачем": {}, "где": {}, "когда": {}, "сколько": {}, "какой": {}, "какая": {}, "какие": {}, "чей": {}}
|
questionWords := map[string]struct{}{"кто": {}, "что": {}, "как": {}, "почему": {}, "зачем": {}, "где": {}, "когда": {}, "сколько": {}, "какой": {}, "какая": {}, "какие": {}, "чей": {}}
|
||||||
conversationWords := []string{"привет", "здравствуйте", "спасибо", "ку", "здравствуй"}
|
conversationWords := []string{"привет", "здравствуйте", "спасибо", "ку", "здравствуй"}
|
||||||
|
confirmationWords := []string{"хорошо", "ладно", "окей", "ок", "понял", "понятно"}
|
||||||
investigateStems := []string{"разбер", "проверь", "проанализ", "исслед", "выясн", "уточн", "подум", "понят", "посмотри", "попроб", "повтор", "снов"}
|
investigateStems := []string{"разбер", "проверь", "проанализ", "исслед", "выясн", "уточн", "подум", "понят", "посмотри", "попроб", "повтор", "снов"}
|
||||||
directiveStems := []string{"сдел", "запуст", "созд", "настро", "добав", "измени", "помен", "использ", "удал", "напом", "подключ", "исправ", "обрати", "спрос", "найд", "посчитай", "рассчитай", "ответь", "вывед"}
|
directiveStems := []string{"сдел", "запуст", "созд", "настро", "добав", "измени", "помен", "использ", "удал", "напом", "подключ", "исправ", "обрати", "спрос", "найд", "посчитай", "рассчитай", "ответь", "вывед"}
|
||||||
explanatoryRequestStems := []string{"расска", "раска", "объяс", "опиш", "покаж", "подскаж", "сообщ"}
|
explanatoryRequestStems := []string{"расска", "раска", "объяс", "опиш", "покаж", "подскаж", "сообщ"}
|
||||||
@@ -292,6 +293,9 @@ func semanticScores(tokens []string, hasQuestionMark bool, explicitCorrection bo
|
|||||||
if containsStem(token, conversationWords...) {
|
if containsStem(token, conversationWords...) {
|
||||||
scores[interaction.SpeechActConversational] += 3
|
scores[interaction.SpeechActConversational] += 3
|
||||||
}
|
}
|
||||||
|
if containsExactToken(token, confirmationWords...) {
|
||||||
|
scores[interaction.SpeechActConfirmation] += 3
|
||||||
|
}
|
||||||
if containsStem(token, investigateStems...) {
|
if containsStem(token, investigateStems...) {
|
||||||
scores[interaction.SpeechActRequestToInvestigate] += 3
|
scores[interaction.SpeechActRequestToInvestigate] += 3
|
||||||
scores[interaction.SpeechActQuestion]++
|
scores[interaction.SpeechActQuestion]++
|
||||||
@@ -810,6 +814,15 @@ func containsStem(token string, stems ...string) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func containsExactToken(token string, words ...string) bool {
|
||||||
|
for _, word := range words {
|
||||||
|
if token == word {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
func containsStemInTokens(tokens []string, stems ...string) bool {
|
func containsStemInTokens(tokens []string, stems ...string) bool {
|
||||||
for _, token := range tokens {
|
for _, token := range tokens {
|
||||||
if containsStem(token, stems...) {
|
if containsStem(token, stems...) {
|
||||||
|
|||||||
@@ -314,6 +314,18 @@ func TestRememberedPreferenceIsNotRenderedAsIdentity(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestStableAcknowledgementsDoNotBecomeTravelRequests(t *testing.T) {
|
||||||
|
for _, message := range []string{"Хорошо", "Ладно", "Понял"} {
|
||||||
|
candidate := BuildDeterministicCandidate(message, "", time.Unix(10, 0).UnixMilli())
|
||||||
|
if candidate.PrimarySpeechAct != interaction.SpeechActConfirmation {
|
||||||
|
t.Fatalf("%q: expected confirmation, got %s", message, candidate.PrimarySpeechAct)
|
||||||
|
}
|
||||||
|
if reply, stable := StableConversationalReply(message, candidate.PrimarySpeechAct); !stable || reply != "Хорошо." {
|
||||||
|
t.Fatalf("%q: stable reply = %q, %t", message, reply, stable)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestCreativeRequestsDoNotRouteToWebResearch(t *testing.T) {
|
func TestCreativeRequestsDoNotRouteToWebResearch(t *testing.T) {
|
||||||
for _, message := range []string{"нарисуй круг", "расскажи сказку о колобке"} {
|
for _, message := range []string{"нарисуй круг", "расскажи сказку о колобке"} {
|
||||||
candidate := BuildDeterministicCandidate(message, "", time.Now().UnixMilli())
|
candidate := BuildDeterministicCandidate(message, "", time.Now().UnixMilli())
|
||||||
|
|||||||
Reference in New Issue
Block a user