You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mail-yubao/scripts/patch-classify-packing-narr...

38 lines
1.1 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

import fs from "fs";
const path = "src/services/parse/classify.ts";
let src = fs.readFileSync(path, "utf8");
const re =
/ \/\/ 金样:[\s\S]*?matched: "xlsx",\r?\n source: "attachment",\r?\n \}\);\r?\n \}/;
const neu = ` // 金样:数据模<E68DAE>?/ 明确预报清单附件 <20>?NEW_CONTAINER(不把单纯「卡派资料」当预报<E9A284>?
const forecastPacking = filenames.some(
(f) =>
/数据模版/i.test(f) ||
(/预报资料|货件清单|装箱清单/i.test(f) &&
/\\.(xlsx|xls|csv)$/i.test(f)),
);
if (forecastPacking) {
const add = scores.NEW_CONTAINER < 40 ? 45 : 15;
signals.push({
signal: "预报清单附件",
score: add,
matched:
filenames.find((f) =>
/数据模版|预报资料|货件清单|装箱清单/i.test(f),
) || "xlsx",
source: "attachment",
});
scores.NEW_CONTAINER += add;
}`;
if (!re.test(src)) {
const i = src.indexOf("金样");
console.log("fail", i, JSON.stringify(src.slice(i, i + 250)));
process.exit(1);
}
src = src.replace(re, neu);
fs.writeFileSync(path, src);
console.log("narrowed ok");