Preserve context across conversation intents (V-542)
Owner explicitly requested direct commits to master; bypass the branch-only hook.
This commit is contained in:
@@ -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 "это", "этого", "этому", "этим", "этом", "эти", "эта":
|
||||
|
||||
Reference in New Issue
Block a user