增加铁路OCR金额字段安全诊断(07-28-travel-reimbursement-guide)
ci-e2e / e2e (push) Canceled after 0s
ci-minimal / check-minimal (push) Canceled after 0s

这个提交包含在:
2026-07-29 15:07:58 +08:00
父节点 26562255a0
当前提交 5f2788ccac
共修改 7 个文件,包含 179 行新增和 1 行删除
+24
查看文件
@@ -131,6 +131,28 @@ function buildFieldHits(normalized) {
);
}
function buildTrainAmountDiagnostics(providerResult) {
if (providerResult?.documentCategory !== "electronic_train_ticket") {
return null;
}
const source = providerResult?.diagnostics?.trainAmountFields;
const booleanValue = (field, key) => source?.[field]?.[key] === true;
return {
totalPresent: booleanValue("total", "present"),
totalIsString: booleanValue("total", "isString"),
totalIsNumber: booleanValue("total", "isNumber"),
totalNonEmpty: booleanValue("total", "nonEmpty"),
totalParseable: booleanValue("total", "parseable"),
farePresent: booleanValue("fare", "present"),
fareIsString: booleanValue("fare", "isString"),
fareIsNumber: booleanValue("fare", "isNumber"),
fareNonEmpty: booleanValue("fare", "nonEmpty"),
fareParseable: booleanValue("fare", "parseable"),
};
}
function buildErrorSummary(alias, error) {
return {
alias: SAFE_ALIAS_PATTERN.test(alias) ? alias : "SAMPLE-PDF-UNKNOWN",
@@ -174,6 +196,7 @@ async function runLiveSampleCheck({
documentSubtype: safeToken(normalized.documentSubtype),
documentCount: Number.isInteger(normalized.documentCount) ? normalized.documentCount : null,
fieldHits: buildFieldHits(normalized),
trainAmountDiagnostics: buildTrainAmountDiagnostics(providerResult),
missingRequiredFields: qualityError?.startsWith("missing_required_fields:")
? qualityError.slice("missing_required_fields:".length).split(",").filter(Boolean)
: [],
@@ -211,6 +234,7 @@ if (import.meta.url === invokedPath) {
export {
LiveOcrSampleError,
buildErrorSummary,
buildTrainAmountDiagnostics,
parseArgs,
readBoundedStdin,
runLiveSampleCheck,