fix: route source-dependent questions to research
This commit is contained in:
@@ -405,6 +405,9 @@ func capabilityHintsFor(primary, secondary interaction.SpeechAct, tokens []strin
|
||||
if primary == interaction.SpeechActQuestion || primary == interaction.SpeechActRequestToInvestigate || secondary == interaction.SpeechActQuestion || secondary == interaction.SpeechActRequestToInvestigate {
|
||||
add("COGNITIVE_REASONING")
|
||||
}
|
||||
if sourceDependentQuestion(primary, secondary, tokens) {
|
||||
add("WEB_RESEARCH")
|
||||
}
|
||||
if containsToken(tokens, "напомни") || containsToken(tokens, "напомин") {
|
||||
add("SCHEDULE_REMINDER")
|
||||
}
|
||||
@@ -446,6 +449,20 @@ func capabilityHintsFor(primary, secondary interaction.SpeechAct, tokens []strin
|
||||
return values
|
||||
}
|
||||
|
||||
// sourceDependentQuestion identifies semantic classes whose answer depends on
|
||||
// a current or externally observed source. It intentionally uses no named
|
||||
// place, person or one-off question branch; when the cue is absent the
|
||||
// truth-first fallback remains in force.
|
||||
func sourceDependentQuestion(primary, secondary interaction.SpeechAct, tokens []string) bool {
|
||||
inquiry := primary == interaction.SpeechActQuestion || primary == interaction.SpeechActRequestToInvestigate || secondary == interaction.SpeechActQuestion || secondary == interaction.SpeechActRequestToInvestigate
|
||||
if !inquiry {
|
||||
return false
|
||||
}
|
||||
currentCue := containsStemInTokens(tokens, "сейчас", "сегодня", "текущ", "актуаль", "последн", "прямо")
|
||||
observedStateCue := containsStemInTokens(tokens, "погод", "температур", "осад", "ветер", "курс", "цен", "стоим", "новост", "распис", "событ", "статус", "доступен", "работает", "запущен", "срок")
|
||||
return currentCue || observedStateCue
|
||||
}
|
||||
|
||||
func informationRequestKind(message string, candidate interaction.SemanticCandidate) interaction.InformationRequestKind {
|
||||
tokens := semanticTokens(message)
|
||||
if len(tokens) == 0 {
|
||||
|
||||
@@ -133,6 +133,25 @@ func TestInformationRequestsAreClassifiedOnceByInteraction(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSourceDependentQuestionRequestsWebResearchWithoutEntityBranch(t *testing.T) {
|
||||
candidate := BuildDeterministicCandidate("какая погода в Киеве?", "", time.Unix(10, 0).UnixMilli())
|
||||
seen := false
|
||||
for _, hint := range candidate.CapabilityHints {
|
||||
if hint == "WEB_RESEARCH" {
|
||||
seen = true
|
||||
}
|
||||
}
|
||||
if !seen {
|
||||
t.Fatalf("source-dependent question was not routed to WEB_RESEARCH: %+v", candidate)
|
||||
}
|
||||
ordinary := BuildDeterministicCandidate("что такое гравитация?", "", time.Unix(10, 0).UnixMilli())
|
||||
for _, hint := range ordinary.CapabilityHints {
|
||||
if hint == "WEB_RESEARCH" {
|
||||
t.Fatalf("ordinary conceptual question was incorrectly routed to WEB_RESEARCH: %+v", ordinary)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestDeterministicCandidateKeepsFirstPersonCompletedWorkAsAssertion(t *testing.T) {
|
||||
candidate := BuildDeterministicCandidate("Я всё уже настроил.", "", time.Unix(10, 0).UnixMilli())
|
||||
if candidate.PrimarySpeechAct != interaction.SpeechActAssertion {
|
||||
|
||||
Reference in New Issue
Block a user