Files
MorphDoc/scripts/docx-real-world-corpus.mjs
T
SkyJourney 64445322eb release: 发布 v0.6.2 DOCX 真实文档修复
新增能力:将 DOCX 发布验收拆分为四套独立 140,支持真实语料冻结、指纹复用、失败与基础设施错误独立统计,并为表格换行、全 JSON 围栏、代码连续性和长文档分页建立通用门禁。

问题修复:冻结 Paged.js 分片前的逻辑表格列轨并传递打印几何,统一 Markdown 表格换行、代码、段落与 OOXML 翻译;改进 PDF 文本流排序、语义块映射、颜色与栅格比较,消除窄字符重叠和跨行范围符号误报。

兼容与部署:版本统一为 0.6.2;正式 Docker 镜像内置固定 Chromium、Pandoc 3.9.0.2 和 Serif/Sans/Mono 字体;Desktop NSIS 与 ZIP 继续直接内置字体,无需系统字体安装。

验证结果:合成基线与长庆严格 280/280,M4N 140/140;健康数据残余误报 6/115(5.22%),均核查为重复表头自动对齐/取样误报且基础设施错误为 0。全项目测试、类型检查、生产构建和 git diff --check 通过;正式 Docker、NSIS、ZIP、离线镜像、部署包、清单及 SHA-256 均已生成并校验。
2026-08-26 10:50:20 +08:00

101 lines
3.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import fs from "node:fs";
import path from "node:path";
export const DOCX_REAL_WORLD_CORPUS = Object.freeze([
{
id: "changqing-tender-requirements",
label: "长庆油田智能健康技术服务招标技术要求",
markdownPath: "tmp/长庆油田智能健康技术服务招标技术要求.md",
requiredFeatures: ["inline-code", "table-math-alignment"]
},
{
id: "health-data-schema",
label: "运动健康类和营养饮食数据结构升级",
markdownPath: "tmp/运动健康类和营养饮食数据数据结构升级.md",
requiredFeatures: ["json-code-indentation"],
codeIndentationProbe: {
rootLine: "{",
nestedLineIncludes: '"heart_rate_daily"',
minimumIndentPt: 4
}
},
{
id: "m4n-table-design",
label: "M4N 全量表设计模块化讲解",
markdownPath: "tmp/数据中台项目周报_2026_W30_附件_M4N全量表设计模块化讲解.md",
requiredFeatures: ["mermaid", "long-document"]
}
]);
export function resolveDocxRealWorldCorpus(repositoryDirectory) {
return DOCX_REAL_WORLD_CORPUS.map((entry) => ({
...entry,
absoluteMarkdownPath: path.resolve(
repositoryDirectory,
entry.markdownPath
),
byteLength: fs.existsSync(path.resolve(repositoryDirectory, entry.markdownPath))
? fs.statSync(path.resolve(repositoryDirectory, entry.markdownPath)).size
: 0
}));
}
export function sortDocxRealWorldCorpusBySize(repositoryDirectory) {
return resolveDocxRealWorldCorpus(repositoryDirectory).sort(
(first, second) =>
first.byteLength - second.byteLength ||
first.id.localeCompare(second.id, "en")
);
}
export function validateDocxRealWorldCorpus(repositoryDirectory) {
const corpus = sortDocxRealWorldCorpusBySize(repositoryDirectory);
const failures = [];
for (const entry of corpus) {
if (!fs.existsSync(entry.absoluteMarkdownPath)) {
failures.push(`${entry.id} 缺少 Markdown${entry.markdownPath}`);
continue;
}
const source = fs.readFileSync(entry.absoluteMarkdownPath, "utf8");
if (!source.trim()) {
failures.push(`${entry.id} Markdown 为空`);
}
if (
entry.requiredFeatures.includes("json-code-indentation") &&
!/```json\s*[\s\S]*?\n[\t ]+\S/gu.test(source)
) {
failures.push(`${entry.id} 缺少带缩进的 JSON 围栏探针`);
}
if (
entry.requiredFeatures.includes("inline-code") &&
!/(^|[^`])`[^`\n]+`([^`]|$)/mu.test(source)
) {
failures.push(`${entry.id} 缺少行内代码探针`);
}
if (
entry.requiredFeatures.includes("table-math-alignment") &&
!/^\|.*\$[^$]+\$.*\|/mu.test(source)
) {
failures.push(`${entry.id} 缺少表格公式对齐探针`);
}
}
return { corpus, failures };
}
export function summarizeDocxReleaseGateMatrix({
baselineCaseCount,
corpusCaseCounts
}) {
const corpusCaseCount = Object.values(corpusCaseCounts).reduce(
(sum, value) => sum + value,
0
);
return {
baselineCaseCount,
corpusDocumentCount: Object.keys(corpusCaseCounts).length,
corpusCaseCounts,
corpusCaseCount,
totalCaseCount: baselineCaseCount + corpusCaseCount
};
}