Harden item occurrence grounding

This commit is contained in:
2026-08-06 13:37:21 +00:00
parent 8cf03a2a44
commit 4192aa8584
16 changed files with 152 additions and 121 deletions

View File

@@ -8,10 +8,8 @@ import (
"fmt"
"strings"
"golang.org/x/text/cases"
"golang.org/x/text/unicode/norm"
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd"
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
)
const (
@@ -51,17 +49,7 @@ func NormalizeDisplay(value string) string {
// ComparisonKey returns the stable key used for item-type identity comparisons.
func ComparisonKey(value string) string {
value = norm.NFKC.String(value)
value = strings.Map(func(r rune) rune {
switch r {
case '\u2018', '\u2019', '\u02bc':
return '\''
default:
return r
}
}, value)
value = strings.Join(strings.Fields(value), " ")
return cases.Fold().String(value)
return shared.ComparisonKey(value)
}
// DeriveID returns the deterministic ID for an item type. Empty identity keys