catalog/repos/20041002liu-cloud--pdf-word-reader-zh.md

71 lines
2.1 KiB
Markdown
Raw Permalink 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.

# PDF/DOCX智能文档解析
`PDF` `文档理解` `OCR` `DOCX` `PPTX` `文本提取`
# pdf-word-reader-zh
```bash
$ npx skills add https://github.com/20041002liu-cloud/pdf-word-reader-zh
```
SKILL.md
本技能为 PDF、DOCX 和 PPTX 文件提供端到端的文档理解能力。它将文件路径转化为结构化提取结果、分块证据以及可供分析的报告。
用户提供文档路径,并要求读取、摘要、提取、分析或完整理解其内容。
## 功能概述
- 读取 `.pdf` 文件,支持文本提取及 OCR 兜底
- 读取 `.docx` 文件,支持段落/表格提取
- 自动将 `.pptx` 转换为 PDF再按 PDF 流程处理
- 将长文本切分为分块证据(`C001``C002`……)
- 生成基于证据的结论报告框架
## 工作流程
1. 检测输入类型PDF、DOCX 或 PPTX。
2. 若为 PPTX先转换为 PDFLibreOffice 或 Windows 上的 PowerPoint COM
3. 提取结构化内容(文本、页面、可用时含表格)。
4. 对低文本量 PDF 页面启用 OCR 兜底。
5. 构建带有稳定块 ID 的证据分块。
6. 输出包含分块证据索引的分析报告框架。
## 命令
```bash
python scripts/prepare_document_context.py "<输入文件>" --output-dir "output/document-understanding"
```
## 输出文件
- `01_extracted.json`:结构化提取结果
- `02_chunks.json`:分块证据单元
- `03_understanding_report.md`:分析报告框架及证据索引
## 常用选项
- `--disable-ocr`:禁用 OCR 兜底
- `--max-pages N`:仅处理前 N 页(快速运行)
- `--fail-on-empty`:若未提取到文本则报错退出
## 依赖安装
```bash
python -m pip install -r requirements.txt
```
推荐系统工具:
- `tesseract`,需安装中文语言包(`chi_sim`
- `pdftoppm`Poppler
- PPTX 转换:`soffice`LibreOffice或 Microsoft PowerPointWindows
## 质量规范
最终分析输出须遵守以下规则:
- 在得出结论前,读取所有分块内容。
- 对关键论点引用块 ID例如 `[C003][C011]`
- 区分事实与假设。
- 明确列出缺失的证据。