fix: propagate recognized person names across local DOCX segments

The local DOCX flow analyzes each paragraph separately, so the backend's
per-text person propagation never crosses paragraph boundaries. A name
recognized once ("Frau Jorinde Quastenberg") stayed in clear text wherever
the model missed it in context ("bei Quastenberg nachfragen").

After all segment batches of a file, add the remaining occurrences of
confidently recognized full names, their parts (3+ characters) and names
after a salutation (including a genitive s) as reviewable PERSON hits.
Whitelist, placeholder filtering and the hit review still apply.

Synthetic reproduction with de_core_news_lg: 59 unmasked name occurrences
before, 0 after; comments, insertions, deletions and anchors verified.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-30 15:48:09 +00:00
parent d2ed7130f0
commit dd0ac92518
4 changed files with 218 additions and 7 deletions

View File

@@ -8,6 +8,7 @@ import { analyzeDocxSegments } from "../velum";
import type { EntityType, PlaceholderMapping } from "../types";
import { checkedImageReport } from "./image-policy";
import type { ImagePolicy } from "./image-policy";
import { propagateDocxPersons } from "./person-propagation";
import { MAX_BATCH_CODEPOINTS } from "./project-review";
import { projectTextAnalyzer } from "./project-text-mapping";
import type { Hit } from "./project-work";
@@ -108,7 +109,9 @@ export async function inspectDocx(
size += segment.text.length + 2;
}
await flush();
return { hits, mapping: current, segmentCount: segments.length };
const propagated = types.includes("PERSON") ? propagateDocxPersons(segments, hits, current, relative)
: { hits, mapping: current };
return { ...propagated, segmentCount: segments.length };
}
export async function writeDocx(