This commit is contained in:
@@ -602,6 +602,9 @@ func informationRequestKind(message string, candidate interaction.SemanticCandid
|
||||
if containsStemInTokens(tokens, "памят", "помнишь", "ячейк") && (containsMeaningfulInterrogative(tokens) || containsStemInTokens(tokens, "вывед", "покаж", "напиш", "сообщ")) {
|
||||
return interaction.InformationRequestMemoryInventory
|
||||
}
|
||||
if containsStemInTokens(tokens, "разниц") && containsStemInTokens(tokens, "времен", "час") {
|
||||
return interaction.InformationRequestTimeDifference
|
||||
}
|
||||
inquiry := candidate.PrimarySpeechAct == interaction.SpeechActQuestion || candidate.PrimarySpeechAct == interaction.SpeechActRequestToInvestigate || candidate.SecondarySpeechAct == interaction.SpeechActQuestion || candidate.SecondarySpeechAct == interaction.SpeechActRequestToInvestigate
|
||||
cognitiveSubject := containsStemInTokens(tokens, "модел", "ии", "ai", "локальн", "когнитив", "канал")
|
||||
inventoryCue := containsStemInTokens(tokens, "список", "доступ", "подключ", "вариант") || (containsMeaningfulInterrogative(tokens) && containsStemInTokens(tokens, "настро"))
|
||||
@@ -623,6 +626,19 @@ func informationRequestKind(message string, candidate interaction.SemanticCandid
|
||||
return ""
|
||||
}
|
||||
|
||||
func LocationContextReply(message string) string {
|
||||
tokens := semanticTokens(message)
|
||||
if len(tokens) < 4 || tokens[0] != "я" || !containsStemInTokens(tokens, "сейчас", "нахож", "жив") {
|
||||
return ""
|
||||
}
|
||||
for index, token := range tokens {
|
||||
if (token == "в" || token == "на") && index+1 < len(tokens) {
|
||||
return "Запомнил: сейчас вы в " + capitalizeWord(tokens[index+1]) + "."
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func boundedConfidence(primaryScore, secondaryScore int, scores map[interaction.SpeechAct]int) int64 {
|
||||
total := 0
|
||||
for _, score := range scores {
|
||||
|
||||
@@ -215,6 +215,20 @@ func TestMemoryInventoryRequestIsSemantic(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestLocationContextReply(t *testing.T) {
|
||||
if got := LocationContextReply("я сейчас в Москве"); got != "Запомнил: сейчас вы в Москве." {
|
||||
t.Fatalf("unexpected location reply %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestTimeDifferenceRequestIsSemantic(t *testing.T) {
|
||||
message := "какая разница во времени между Москвой и Шанхаем?"
|
||||
candidate := BuildDeterministicCandidate(message, "", time.Unix(10, 0).UnixMilli())
|
||||
if got := informationRequestKind(message, candidate); got != interaction.InformationRequestTimeDifference {
|
||||
t.Fatalf("expected time difference, got %q", got)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeterministicCandidateKeepsFirstPersonCompletedWorkAsAssertion(t *testing.T) {
|
||||
candidate := BuildDeterministicCandidate("Я всё уже настроил.", "", time.Unix(10, 0).UnixMilli())
|
||||
if candidate.PrimarySpeechAct != interaction.SpeechActAssertion {
|
||||
|
||||
@@ -189,6 +189,11 @@ func TravelSearchClarification(message string, history []interaction.HumanUttera
|
||||
}
|
||||
}
|
||||
}
|
||||
if !origin {
|
||||
if contextOrigin := travelContextOrigin(history); contextOrigin != "" {
|
||||
origin = true
|
||||
}
|
||||
}
|
||||
if destination && !origin && !date {
|
||||
if !ticketRequest {
|
||||
return "Из какого города выезжать в " + destinationLabel(current, history) + "? Подберу самолёт, поезд, автобус или машину."
|
||||
@@ -238,6 +243,21 @@ func travelContextDestination(history []interaction.HumanUtterance) string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func travelContextOrigin(history []interaction.HumanUtterance) string {
|
||||
for index := len(history) - 1; index >= 0; index-- {
|
||||
tokens := semanticTokens(history[index].Content)
|
||||
if len(tokens) < 3 || tokens[0] != "я" || !containsStemInTokens(tokens, "сейчас", "нахож", "жив") {
|
||||
continue
|
||||
}
|
||||
for tokenIndex, token := range tokens {
|
||||
if (token == "в" || token == "из") && tokenIndex+1 < len(tokens) {
|
||||
return capitalizeWord(tokens[tokenIndex+1])
|
||||
}
|
||||
}
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func travelContextCue(tokens []string) bool {
|
||||
return travelCue(tokens) || containsStemInTokens(tokens, "добрат", "передвиг", "ехать", "едем", "лететь", "поездк")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user