From cde9b1cfb14dbb9d5370a0b0ae25857d1291e423 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roberto=20Trevi=C3=B1o?= Date: Sun, 29 Nov 2026 12:39:07 -0600 Subject: [PATCH] =?UTF-8?q?Revisi=C3=B3n:=20documents=20no=20route=20recog?= =?UTF-8?q?nises;=20reasons=20and=20fields=20in=20Spanish?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/revision/revision.html | 62 ++++++++++++++++++++--- src/app/revision/revision.scss | 8 +++ src/app/revision/revision.ts | 93 ++++++++++++++++++++++++++++++++++ 3 files changed, 155 insertions(+), 8 deletions(-) diff --git a/src/app/revision/revision.html b/src/app/revision/revision.html index a1dfab2..e3787cd 100644 --- a/src/app/revision/revision.html +++ b/src/app/revision/revision.html @@ -30,14 +30,14 @@ - @for (row of held.value() ?? []; track row['_record']) { + @for (row of held.value() ?? []; track $index) { {{ row['_pipeline'] }} · {{ row['_target'] }} - {{ reasons(row) }} + {{ said(row) }} @for (v of values(row) | keyvalue; track v.key) { {{ v.key }}{{ title(v.key) }}: {{ text(v.value) }} } @@ -84,7 +84,7 @@ - @for (row of conflicts.value() ?? []; track row['_record']) { + @for (row of conflicts.value() ?? []; track $index) { {{ text(row['person_id']).slice(0, 10) }} @@ -92,7 +92,7 @@ @for (v of values(row) | keyvalue; track v.key) { {{ v.key }}{{ title(v.key) }}: {{ text(v.value) }} } @@ -116,6 +116,52 @@ + +
+ + Canalización + + @for (p of pipelines.value() ?? []; track p['pipeline_id']) { + {{ p['pipeline_id'] }} + } + + +
+

+ Lo que llegó de la fuente y ninguna ruta reconoce: un formato nuevo, un estudio que la + plataforma no conoce o un escaneo ilegible. Para incluirlo, agregue o ajuste una ruta en + Conectar. +

+ @if (unrecognised.isLoading()) { + + } @else { + + + + + + + + + + @for (row of unrecognised.value() ?? []; track $index) { + + + + + + } @empty { + + + + } + +
RutaOrigenInicio del texto
{{ row['route'] }}{{ details(row) }} +
{{ row['preview'] || '(sin texto legible)' }}
+
Ningún documento sin reconocer.
+ } +
+
@@ -158,7 +204,7 @@ @for (entry of p['to_settle']; track entry['person']) {
- Registro {{ text(entry['person']).slice(0, 10) }} · + Registro&ngsp;{{ text(entry['person']).slice(0, 10) }} · {{ text(entry['record_number']) }} · {{ text(entry['full_name']) }} · {{ text(entry['birth_date']) }}
@@ -170,7 +216,7 @@ }} · {{ text(c['full_name']) }} · {{ text(c['birth_date']) }})? {{ c['reason'] }} + >{{ candidateReason(c['reason']) }} @if (c['probability'] !== null) { · p = {{ $any(c['probability']) | number: '1.2-2' }} } @@ -200,7 +246,7 @@

Registros que no coinciden en fecha de nacimiento o sexo ({{ p['torn'].length }})

@for (entry of p['torn']; track entry['person']) {
- @for (r of records(entry); track r['_record']) { + @for (r of records(entry); track $index) {
@for (v of values(r) | keyvalue; track v.key) { diff --git a/src/app/revision/revision.scss b/src/app/revision/revision.scss index 41e6575..2b9a10b 100644 --- a/src/app/revision/revision.scss +++ b/src/app/revision/revision.scss @@ -46,3 +46,11 @@ h2 { .small { width: 160px; } + +.preview { + margin: 0; + max-height: 8em; + overflow: auto; + white-space: pre-wrap; + font-size: 12px; +} diff --git a/src/app/revision/revision.ts b/src/app/revision/revision.ts index efd63fb..59972e6 100644 --- a/src/app/revision/revision.ts +++ b/src/app/revision/revision.ts @@ -15,6 +15,9 @@ import { conflicts } from '../api/fn/review/conflicts'; import { correct } from '../api/fn/review/correct'; import { decidePersons } from '../api/fn/review/decide-persons'; import { held } from '../api/fn/review/held'; +import { Loading } from '../loading'; +import { schema } from '../api/fn/ingest/schema'; +import { unrecognised } from '../api/fn/review/unrecognised'; import { persons } from '../api/fn/review/persons'; import { reject } from '../api/fn/review/reject'; import { runStatus } from '../api/fn/runs/run-status'; @@ -46,6 +49,39 @@ const IDENTITY_FIELDS: Correction['field'][] = [ 'birth_date', 'sex', ]; +/** Identity fields as linkage names them (core.schema.Identity). */ +const IDENTITY_TITLES: Record = { + record_number: 'Expediente', + curp: 'CURP', + nss: 'NSS', + full_name: 'Nombre', +}; + +/** The platform's hold reasons (English in its logs) as the reviewer reads them. */ +const REASONS: [RegExp, (m: RegExpExecArray) => string][] = [ + [/^Field required$/, () => 'falta el dato'], + [ + /^Input should be (.+)$/, + (m) => `valor fuera del catálogo (se espera ${m[1].replace(/ or /g, ' o ')})`, + ], + [/^not found in the document as quoted$/, () => 'no está en el documento tal como se citó'], + [/^Value error, a date is not a record number$/, () => 'una fecha no es un expediente'], + [ + /^records of this person disagree on birth date or sex$/, + () => 'sus registros no coinciden en fecha de nacimiento o sexo', + ], + [ + /^no name, birth date or record number was read$/, + () => 'no se leyó nombre, fecha de nacimiento ni expediente', + ], + [/^no identity linked to this record$/, () => 'ninguna identidad vinculada a este registro'], + [/^nothing found$/, () => 'no se encontró nada en el documento'], + [ + /^no LLM answering and no patterns set$/, + () => 'sin modelo de lenguaje disponible ni patrones configurados', + ], +]; + /** Bookkeeping columns, not values a reviewer judges. */ const HIDDEN = [ '_pipeline', @@ -64,6 +100,7 @@ const HIDDEN = [ @Component({ selector: 'app-revision', imports: [ + Loading, DecimalPipe, KeyValuePipe, FormsModule, @@ -115,6 +152,20 @@ export class Revision { : Promise.resolve({ to_settle: [], torn: [] } as Record), }); + /** Documents the chosen pipeline's routes don't recognise (its `otherwise` routes). */ + protected readonly unrecognised = resource({ + params: () => this.pipeline(), + loader: ({ params }) => + params ? this.api.invoke(unrecognised, { pipeline: params }) : Promise.resolve([] as Row[]), + }); + /** A row's fields but its route and preview, as `name: value`. */ + protected details(row: Row): string { + return Object.entries(row) + .filter(([k, v]) => !['route', 'preview'].includes(k) && v !== null && v !== '') + .map(([k, v]) => `${k}: ${v}`) + .join(' · '); + } + protected readonly message = signal(''); protected readonly decided = signal(new Set()); protected readonly run = signal(''); @@ -130,6 +181,48 @@ export class Revision { const found = row['_held']; return Array.isArray(found) ? found.join('; ') : String(found ?? ''); } + /** The platform's field titles (the catalog's), by entity: what the page calls a field. */ + protected readonly titles = resource({ + loader: async () => { + const found = (await this.api.invoke(schema)) as Record; + return Object.fromEntries( + Object.entries((found['entities'] ?? {}) as Record).map(([e, s]) => [ + e, + Object.fromEntries( + Object.entries((s['properties'] ?? {}) as Record).map(([f, p]) => [ + f, + p['title'] as string, + ]), + ), + ]), + ) as Record>; + }, + }); + protected title(field: string): string { + return this.titles.value()?.[this.entity()]?.[field] ?? field; + } + /** A hold's reasons as the reviewer reads them (the platform logs them in English). */ + protected said(row: Row): string { + const found = row['_held']; + const all = Array.isArray(found) ? (found as string[]) : [String(found ?? '')]; + return all.map((r) => this.spanish(r)).join('; '); + } + /** Why linkage proposes two records as one person, in the reviewer's words. */ + protected candidateReason(reason: unknown): string { + const text = String(reason ?? ''); + const typo = /^(\w+) one typo apart$/.exec(text); + if (typo) return `${IDENTITY_TITLES[typo[1]] ?? typo[1]} a una letra de distancia`; + return text === 'same birth date' ? 'misma fecha de nacimiento' : text; + } + private spanish(reason: string): string { + const field = /^(\w+): (.*)$/.exec(reason); + const [name, message] = field ? [this.title(field[1]) + ': ', field[2]] : ['', reason]; + for (const [pattern, text] of REASONS) { + const m = pattern.exec(message); + if (m) return name + text(m); + } + return reason; + } protected text(value: unknown): string { return typeof value === 'object' && value !== null ? JSON.stringify(value)