router: sweep dead double-loop and drifted anaphora comment (V-581)

narrativeQueryBuild reimplemented the "any token in list" check the
package already has as hasTok; use it instead of a nested loop.

AnaphoraResolver's doc comments described a stale return shape (a
key/value pair) and an incomplete pronoun list (missing the "that" and
"mine" classes the switch already handled) — fixed the comments to
match the code, no behaviour change.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
2026-08-06 02:27:54 +04:00
parent d70cb7e9ab
commit 41d3a4a903
2 changed files with 16 additions and 13 deletions
+8 -4
View File
@@ -438,18 +438,22 @@ func parseDurationValue(s string) (string, bool) {
}
// AnaphoraResolver resolves pronouns like "это", "он", "она" to the prior
// turn's key entity. Returns a (key, value) pair the prior fact carried,
// or ("", "", false) when no pronoun is detected.
// turn's key entity. Returns the matched pronoun's class as ref, or
// ("", false) when no pronoun is detected — the caller cross-references ref
// against the prior turn's own slots, this type holds no state of its own.
type AnaphoraResolver struct{}
// Resolve checks if text contains an anaphoric reference to a prior turn's
// entity. For MVP this handles the common Russian pronouns:
// - "это" / "этого" / "этому" / "этим" / "этом" → "this" (most common)
// - "это" / "этого" / "этому" / "этим" / "этом" / "эти" / "эта" → "this"
// (most common)
// - "он" / "его" / "ему" / "ним" → "he/it", masc
// - "она" / "её" / "ей" / "ней" → "she/it", fem
// - "оно" → "it", neuter
// - "тот" / "та" / "то" / "те" → "that"
// - "мой" and its declined forms → "mine"
//
// Returns the matching pronoun type for cross-referencing with prior slots.
// Returns the matching pronoun class for cross-referencing with prior slots.
func (AnaphoraResolver) Resolve(text string) (ref string, ok bool) {
s := strings.ToLower(strings.TrimSpace(text))
toks := strings.Fields(s)
+8 -9
View File
@@ -292,16 +292,15 @@ func narrativeQueryBuild(m []string) (Decision, bool) {
if chatNarrativeTopics.MatchString(m[0]) {
return Decision{}, false
}
for _, t := range planTokens(topic) {
for _, v := range captureVerbs {
if t == v {
return Decision{}, false
}
toks := planTokens(topic)
for _, v := range captureVerbs {
if hasTok(toks, v) {
return Decision{}, false
}
for _, v := range entertainmentNouns {
if t == v {
return Decision{}, false
}
}
for _, v := range entertainmentNouns {
if hasTok(toks, v) {
return Decision{}, false
}
}
return Decision{