- spikes/:Word 转 PDF(Gotenberg)、格式识别、原句坐标、DeepSeek 抽取四项验证代码与两版提示词;样本派生产物和 .env 不进 git - tech-validation.md:完整结论。四项都可行:WPS 字体字符集要修正并改用行高调整过的字体;格式识别不需要 Docling;表格内切句待改进;抽取需第三道依据校验与规则兜底 - architecture.md:§3.5 加预处理与字体包,§3.6 证据校验改为三道,§10 回填结论 - 03 功能需求与 decisions.md(TV1):召回 ≥ 99%、采纳准确率 ≥ 95%、页码 100%、高亮正文 ≥ 98% / 表格 ≥ 95% Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
16 lines
894 B
Python
16 lines
894 B
Python
"""统计 PDF 正文页的行距和每页行数,找页数偏差的来源。"""
|
|
import statistics, sys, pdfplumber
|
|
for path in sys.argv[1:]:
|
|
pitches, counts, sizes, fonts = [], [], [], {}
|
|
with pdfplumber.open(path) as pdf:
|
|
for page in pdf.pages[5:25]:
|
|
ys = sorted({round(c["top"], 1) for c in page.chars if c["text"].strip()})
|
|
if len(ys) < 10:
|
|
continue
|
|
counts.append(len(ys))
|
|
pitches += [b - a for a, b in zip(ys, ys[1:]) if 8 < b - a < 40]
|
|
for c in page.chars:
|
|
sizes.append(round(c["size"], 1)); fonts[c["fontname"].split("+")[-1]] = fonts.get(c["fontname"].split("+")[-1], 0) + 1
|
|
print(path.split("/out/")[-1], "lines/page", statistics.median(counts), "pitch", statistics.median(pitches),
|
|
"size", statistics.mode(sizes), sorted(fonts.items(), key=lambda x: -x[1])[:3])
|