fix(pii): give extend_to_previous_word its own settings order

It shared order 215 with extend_to_next_word, so the settings UI had no
defined order between the two. Move it to 216 and shift the protected
terms fields. Pin that a number in front of a hit is never taken.

Assisted-by: Claude Code:claude-sonnet-5-5
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
This commit is contained in:
Ettore Di Giacinto committed 2026-10-13 08:10:55 +00:00
1 parent e3341d21a0
commit f420bfcc26
2 files changed
+4 -4

No files matched your search

+3 -3
View File
@@ -1067,21 +1067,21 @@ func DefaultRegistry() map[string]FieldMetaOverride {
Label: "Extend To Previous Word",
Description: "Entity groups (e.g. LASTNAME) whose detections also cover the word right before them on the same line, with the same action, when that word consists of letters only. Use it when the model tags a surname reliably but scores the first name before it below the threshold.",
Component: "string-list",
Order: 215,
Order: 216,
},
"pii_detection.protected_terms": {
Section: "pii",
Label: "Protected Terms",
Description: "Values that must pass the filter unchanged even when the model tags them, e.g. known business names a name model reads as surnames. Hidden from the detector behind a placeholder and restored afterwards; matched whole-word and case-insensitively, minimum three characters.",
Component: "string-list",
Order: 216,
Order: 217,
},
"pii_detection.protected_terms_files": {
Section: "pii",
Label: "Protected Terms Files",
Description: "Files inside the models path with one protected term per line ('#' starts a comment). Re-read when they change, so an external process can keep the list current without a restart. A missing file is skipped with a warning.",
Component: "string-list",
Order: 217,
Order: 218,
},
// --- Cloud passthrough proxy ---
@@ -45,7 +45,7 @@ var _ = Describe("ExtendToPreviousWord", func() {
})
It("never swallows a word with digits (amounts, dates, codes stay intact)", func() {
for _, text := range []string{"Betrag 12,50 Waldmeister", "am 11.08.2026 Waldmeister", "Zimmer 4711 Waldmeister", "Code A1b Waldmeister"} {
for _, text := range []string{"Betrag 12,50 Waldmeister", "am 11.08.2026 Waldmeister", "Zimmer 4711 Waldmeister", "Code A1b Waldmeister", "12 Waldmeister"} {
det := &stubNERDetector{entities: []NEREntity{ent(text, "Waldmeister", "LASTNAME", 0.9)}}
res, err := RedactNER(ctx, text, []NERConfig{{Detector: det, DefaultAction: ActionMask, ExtendToPreviousWord: []string{"LASTNAME"}}})
Expect(err).NotTo(HaveOccurred())