fix(dn): strip each of the slip's own numbers before looking for a second document
The joined 'DOC|ALT' string never matched the evidence text, so a slip with alternate numbers counted its own numbers as a second document and stayed held in grouping. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
eca2cb845c
commit
c2dbafcaa2
2 changed files with 12 additions and 3 deletions
|
|
@ -92,7 +92,16 @@ describe("background fragments", () => {
|
|||
expect(result.openPages).toEqual([{ page: 1, reason: "multiple_documents" }]);
|
||||
});
|
||||
|
||||
it("groups a fragment with no evidence text at all on a complete page", () => {
|
||||
it("does not mistake the slip's own alternate numbers for a second document", () => {
|
||||
const result = assemblePages([fragment({
|
||||
doc_number_alts: ["07565729", "99058993"],
|
||||
evidence: { multiple_documents: "Partial edge of paper behind slip 07565729 (internal 99058993)." },
|
||||
})]);
|
||||
expect(result.groups.map((group) => group.pages)).toEqual([[1]]);
|
||||
expect(result.openPages).toEqual([]);
|
||||
});
|
||||
|
||||
it("still holds a flagged page whose evidence says nothing about background", () => {
|
||||
const result = assemblePages([fragment({ evidence: {} })]);
|
||||
expect(result.openPages).toEqual([{ page: 1, reason: "multiple_documents" }]);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -132,8 +132,8 @@ function backgroundFragment(read: PageRead): boolean {
|
|||
if (!read.doc_number.trim() || read.items.length === 0) return false;
|
||||
const evidence = read.evidence?.multiple_documents;
|
||||
if (!evidence || !BACKGROUND.test(evidence)) return false;
|
||||
const own = [read.doc_number, ...(read.doc_number_alts ?? [])].join("|");
|
||||
const elsewhere = evidence.replace(own, " ").match(DOCUMENT_NUMBER);
|
||||
const own = [read.doc_number, ...(read.doc_number_alts ?? [])].map((ref) => ref.trim()).filter(Boolean);
|
||||
const elsewhere = own.reduce((text, ref) => text.split(ref).join(" "), evidence).match(DOCUMENT_NUMBER);
|
||||
return elsewhere === null;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue