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:
@@ -438,18 +438,22 @@ func parseDurationValue(s string) (string, bool) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AnaphoraResolver resolves pronouns like "это", "он", "она" to the prior
|
// AnaphoraResolver resolves pronouns like "это", "он", "она" to the prior
|
||||||
// turn's key entity. Returns a (key, value) pair the prior fact carried,
|
// turn's key entity. Returns the matched pronoun's class as ref, or
|
||||||
// or ("", "", false) when no pronoun is detected.
|
// ("", 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{}
|
type AnaphoraResolver struct{}
|
||||||
|
|
||||||
// Resolve checks if text contains an anaphoric reference to a prior turn's
|
// Resolve checks if text contains an anaphoric reference to a prior turn's
|
||||||
// entity. For MVP this handles the common Russian pronouns:
|
// entity. For MVP this handles the common Russian pronouns:
|
||||||
// - "это" / "этого" / "этому" / "этим" / "этом" → "this" (most common)
|
// - "это" / "этого" / "этому" / "этим" / "этом" / "эти" / "эта" → "this"
|
||||||
|
// (most common)
|
||||||
// - "он" / "его" / "ему" / "ним" → "he/it", masc
|
// - "он" / "его" / "ему" / "ним" → "he/it", masc
|
||||||
// - "она" / "её" / "ей" / "ней" → "she/it", fem
|
// - "она" / "её" / "ей" / "ней" → "she/it", fem
|
||||||
// - "оно" → "it", neuter
|
// - "оно" → "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) {
|
func (AnaphoraResolver) Resolve(text string) (ref string, ok bool) {
|
||||||
s := strings.ToLower(strings.TrimSpace(text))
|
s := strings.ToLower(strings.TrimSpace(text))
|
||||||
toks := strings.Fields(s)
|
toks := strings.Fields(s)
|
||||||
|
|||||||
@@ -292,16 +292,15 @@ func narrativeQueryBuild(m []string) (Decision, bool) {
|
|||||||
if chatNarrativeTopics.MatchString(m[0]) {
|
if chatNarrativeTopics.MatchString(m[0]) {
|
||||||
return Decision{}, false
|
return Decision{}, false
|
||||||
}
|
}
|
||||||
for _, t := range planTokens(topic) {
|
toks := planTokens(topic)
|
||||||
for _, v := range captureVerbs {
|
for _, v := range captureVerbs {
|
||||||
if t == v {
|
if hasTok(toks, v) {
|
||||||
return Decision{}, false
|
return Decision{}, false
|
||||||
}
|
|
||||||
}
|
}
|
||||||
for _, v := range entertainmentNouns {
|
}
|
||||||
if t == v {
|
for _, v := range entertainmentNouns {
|
||||||
return Decision{}, false
|
if hasTok(toks, v) {
|
||||||
}
|
return Decision{}, false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Decision{
|
return Decision{
|
||||||
|
|||||||
Reference in New Issue
Block a user