Revisión: documents no route recognises; reasons and fields in Spanish
This commit is contained in:
@@ -30,14 +30,14 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (row of held.value() ?? []; track row['_record']) {
|
||||
@for (row of held.value() ?? []; track $index) {
|
||||
<tr>
|
||||
<td>{{ row['_pipeline'] }} · {{ row['_target'] }}</td>
|
||||
<td>{{ reasons(row) }}</td>
|
||||
<td>{{ said(row) }}</td>
|
||||
<td class="values">
|
||||
@for (v of values(row) | keyvalue; track v.key) {
|
||||
<span
|
||||
><b>{{ v.key }}</b
|
||||
><b>{{ title(v.key) }}</b
|
||||
>: {{ text(v.value) }}</span
|
||||
>
|
||||
}
|
||||
@@ -84,7 +84,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (row of conflicts.value() ?? []; track row['_record']) {
|
||||
@for (row of conflicts.value() ?? []; track $index) {
|
||||
<tr>
|
||||
<td>
|
||||
<code>{{ text(row['person_id']).slice(0, 10) }}</code>
|
||||
@@ -92,7 +92,7 @@
|
||||
<td class="values">
|
||||
@for (v of values(row) | keyvalue; track v.key) {
|
||||
<span
|
||||
><b>{{ v.key }}</b
|
||||
><b>{{ title(v.key) }}</b
|
||||
>: {{ text(v.value) }}</span
|
||||
>
|
||||
}
|
||||
@@ -116,6 +116,52 @@
|
||||
</table>
|
||||
</mat-tab>
|
||||
|
||||
<mat-tab [label]="'Documentos no reconocidos (' + (unrecognised.value()?.length ?? 0) + ')'">
|
||||
<div class="bar">
|
||||
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
||||
<mat-label>Canalización</mat-label>
|
||||
<mat-select [value]="pipeline()" (selectionChange)="pipeline.set($event.value)">
|
||||
@for (p of pipelines.value() ?? []; track p['pipeline_id']) {
|
||||
<mat-option [value]="p['pipeline_id']">{{ p['pipeline_id'] }}</mat-option>
|
||||
}
|
||||
</mat-select>
|
||||
</mat-form-field>
|
||||
</div>
|
||||
<p class="muted">
|
||||
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.
|
||||
</p>
|
||||
@if (unrecognised.isLoading()) {
|
||||
<app-loading what="los documentos no reconocidos" />
|
||||
} @else {
|
||||
<table class="plain">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Ruta</th>
|
||||
<th>Origen</th>
|
||||
<th>Inicio del texto</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@for (row of unrecognised.value() ?? []; track $index) {
|
||||
<tr>
|
||||
<td>{{ row['route'] }}</td>
|
||||
<td class="muted">{{ details(row) }}</td>
|
||||
<td>
|
||||
<pre class="preview">{{ row['preview'] || '(sin texto legible)' }}</pre>
|
||||
</td>
|
||||
</tr>
|
||||
} @empty {
|
||||
<tr>
|
||||
<td colspan="3" class="muted">Ningún documento sin reconocer.</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
}
|
||||
</mat-tab>
|
||||
|
||||
<mat-tab label="Personas">
|
||||
<div class="bar">
|
||||
<mat-form-field appearance="outline" subscriptSizing="dynamic">
|
||||
@@ -158,7 +204,7 @@
|
||||
@for (entry of p['to_settle']; track entry['person']) {
|
||||
<div class="card person">
|
||||
<div>
|
||||
<b>Registro</b> <code>{{ text(entry['person']).slice(0, 10) }}</code> ·
|
||||
<b>Registro</b>&ngsp;<code>{{ text(entry['person']).slice(0, 10) }}</code> ·
|
||||
{{ text(entry['record_number']) }} · {{ text(entry['full_name']) }} ·
|
||||
{{ text(entry['birth_date']) }}
|
||||
</div>
|
||||
@@ -170,7 +216,7 @@
|
||||
}}
|
||||
· {{ text(c['full_name']) }} · {{ text(c['birth_date']) }})?
|
||||
<span class="muted"
|
||||
>{{ c['reason'] }}
|
||||
>{{ candidateReason(c['reason']) }}
|
||||
@if (c['probability'] !== null) {
|
||||
· p = {{ $any(c['probability']) | number: '1.2-2' }}
|
||||
}
|
||||
@@ -200,7 +246,7 @@
|
||||
<h2>Registros que no coinciden en fecha de nacimiento o sexo ({{ p['torn'].length }})</h2>
|
||||
@for (entry of p['torn']; track entry['person']) {
|
||||
<div class="card person">
|
||||
@for (r of records(entry); track r['_record']) {
|
||||
@for (r of records(entry); track $index) {
|
||||
<div class="candidate">
|
||||
<span class="values">
|
||||
@for (v of values(r) | keyvalue; track v.key) {
|
||||
|
||||
@@ -46,3 +46,11 @@ h2 {
|
||||
.small {
|
||||
width: 160px;
|
||||
}
|
||||
|
||||
.preview {
|
||||
margin: 0;
|
||||
max-height: 8em;
|
||||
overflow: auto;
|
||||
white-space: pre-wrap;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
@@ -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<string, string> = {
|
||||
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<string, Row[]>),
|
||||
});
|
||||
|
||||
/** 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<string>());
|
||||
protected readonly run = signal<string>('');
|
||||
@@ -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<string, any>;
|
||||
return Object.fromEntries(
|
||||
Object.entries((found['entities'] ?? {}) as Record<string, any>).map(([e, s]) => [
|
||||
e,
|
||||
Object.fromEntries(
|
||||
Object.entries((s['properties'] ?? {}) as Record<string, any>).map(([f, p]) => [
|
||||
f,
|
||||
p['title'] as string,
|
||||
]),
|
||||
),
|
||||
]),
|
||||
) as Record<string, Record<string, string>>;
|
||||
},
|
||||
});
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user