Files
mdpolish/rules/default.yaml
T
Bepr4 c19e9fcebf govdoc-md-cleaner v0.1.0: 政务文档 Markdown 清洗工具(规则引擎 + CLI + 测试)
- 8 条 YAML 声明规则:页码/页眉页脚/目录点线/图片/HTML表格/散落标签/行尾空白/空行
- 防误伤设计:protect 正则 + 内容形态豁免 + OCR burst 检测
- md-clean single/batch CLI,JSON 清洗报告
- 18 个单元测试

Co-Authored-By: Claude <noreply@anthropic.com>
2026-08-20 17:04:10 +08:00

56 lines
2.1 KiB
YAML
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.
# 政务文档 Markdown 默认清洗规则集
# 每条规则: name(必填,须在引擎 REGISTRY 中注册) / order(应用顺序) / enabled / params
# 针对 PDF→Markdown 管线(MinerU/OCR)产物的典型脏数据。
rules:
# 1) 页码行:"第 X 页 共 Y 页" / "第X页共4页" / "Page 3 of 10" / "3 / 10"
- name: strip_page_lines
order: 10
params:
keep_bare_numbers: true # 单独一行纯数字(可能是页码也可能是编号),默认保留
# 2) 页眉页脚 + OCR 重复崩坏行:
# a) 同一短行全篇重复 >= threshold 次(如逐页出现的项目名、"正本")
# b) 同一短行连续刷屏 >= burst_limit 次(OCR 崩坏,如"审计程序"×1359
# protect 列出"重复但属于正文模板"的保护正则(标书里逐章出现的签章/日期栏)
# 内容形态行(编号条款/列表/表格行)天然重复,已在引擎侧豁免
- name: strip_repeated_short_lines
order: 20
params:
threshold: 3
max_len: 40
burst_limit: 5
burst_gap: 2
protect:
- "公章" # 投标人:(公章)
- "签名|签字|盖章" # 法定代表人签名:
- "日期|年.*月.*日" # 日期: / 日期: 年 月 日
- "^致[:]" # 致:xxx(投标函收件人)
- "负责|声明" # 声明函固定结尾句(中小企业声明函等)
# 3) 目录点线:"第一章 投标邀请函 ……………… 2"(保留标题文字,去掉点线和页码)
- name: strip_toc_dots
order: 30
# 4) 图片引用:![](images/xxx.jpg) 为死链,整行删除
- name: drop_images
order: 40
params:
placeholder: null # 需要保留位置时改为 "[图]" 之类
# 5) HTML 表格 → Markdown 管道表格(<table><tr><td> 单行压缩形态)
- name: normalize_tables
order: 50
# 6) 散落的 <br/> 标签
- name: strip_stray_html
order: 60
# 7) 行尾空白(MinerU 输出每行带双空格硬换行符)
- name: rstrip_lines
order: 70
# 8) 连续空行压为 1 行,裁掉文首文末空白
- name: collapse_blank_lines
order: 80