- 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>
27 lines
859 B
Python
27 lines
859 B
Python
"""技术验证共用:样本定位、格式识别。样本是不可信输入,只读取,不执行。"""
|
||
from __future__ import annotations
|
||
|
||
import pathlib
|
||
|
||
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
||
SAMPLES = ROOT / "samples" / "tenders"
|
||
IDS = [f"S{i:02d}" for i in range(1, 11)]
|
||
|
||
|
||
def sample_file(sid: str) -> pathlib.Path:
|
||
files = [p for p in (SAMPLES / sid).iterdir() if p.suffix.lower() in (".doc", ".docx")]
|
||
assert len(files) == 1, (sid, files)
|
||
return files[0]
|
||
|
||
|
||
def sniff(path: pathlib.Path) -> str:
|
||
"""按文件头识别真实格式(FR-M2-01),不看扩展名。"""
|
||
head = path.read_bytes()[:8]
|
||
if head.startswith(b"PK\x03\x04"):
|
||
return "docx"
|
||
if head.startswith(bytes.fromhex("D0CF11E0A1B11AE1")):
|
||
return "doc"
|
||
if head.startswith(b"%PDF"):
|
||
return "pdf"
|
||
return "unknown"
|