增加铁路OCR金额字段安全诊断(07-28-travel-reimbursement-guide)
这个提交包含在:
@@ -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,
|
||||
|
||||
在新工单中引用
屏蔽一个用户