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.
39 lines
984 B
39 lines
984 B
import fs from "fs";
|
|
import {
|
|
extractMailInstructions,
|
|
splitBodySegments,
|
|
} from "../src/services/parse/split-instructions";
|
|
|
|
const raw = JSON.parse(
|
|
fs.readFileSync("data/logs/mail-pdf-extract.json", "utf8"),
|
|
) as Record<string, string[]>;
|
|
|
|
function bodyOf(keyPart: string): string {
|
|
const key = Object.keys(raw).find((k) => k.includes(keyPart));
|
|
if (!key) return "";
|
|
return raw[key].join("\n");
|
|
}
|
|
|
|
for (const name of ["邮件2", "邮件3", "邮件4"]) {
|
|
const body = bodyOf(name);
|
|
const segs = splitBodySegments(body);
|
|
console.log(`\n==== ${name} segs=${segs.length} bodyLen=${body.length}`);
|
|
segs.forEach((s, i) => {
|
|
console.log(` ${i}: ${s.replace(/\s+/g, " ").slice(0, 100)}`);
|
|
});
|
|
const units = extractMailInstructions({
|
|
subject: "",
|
|
body,
|
|
filenames: [],
|
|
});
|
|
console.log(
|
|
" units",
|
|
units.map((u) => ({
|
|
kind: u.uiKind,
|
|
cur: u.isCurrent,
|
|
seg: u.segmentIndex,
|
|
kw: u.keywords.slice(0, 4),
|
|
})),
|
|
);
|
|
}
|