Preserve context across conversation intents (V-542)

Owner explicitly requested direct commits to master; bypass the branch-only hook.
This commit is contained in:
2026-08-13 02:14:46 +04:00
parent a0e6643465
commit da9114b623
15 changed files with 499 additions and 56 deletions
+7 -2
View File
@@ -5,6 +5,7 @@ import (
"strconv"
"strings"
"time"
"unicode"
"github.com/kami/maven/internal/lexicon"
"github.com/kami/maven/internal/morph"
@@ -507,8 +508,12 @@ type AnaphoraResolver struct{}
//
// 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)
// Pronouns are a closed grammatical class. Split on punctuation instead of
// trying to encode word boundaries in a regexp: "это?" and "его," are the
// same pronouns as "это" and "его", including next to Cyrillic letters.
toks := strings.FieldsFunc(strings.ToLower(strings.TrimSpace(text)), func(r rune) bool {
return !unicode.IsLetter(r) && !unicode.IsDigit(r)
})
for _, tok := range toks {
switch tok {
case "это", "этого", "этому", "этим", "этом", "эти", "эта":