feat: 统一文档解析器项目 - 迁移 lyxy-reader-office 和 lyxy-reader-html

## 功能特性

- 建立统一的项目结构,包含 core/、readers/、utils/、tests/ 模块
- 迁移 lyxy-reader-office 的所有解析器(docx、xlsx、pptx、pdf)
- 迁移 lyxy-reader-html 的所有解析器(html、url 下载)
- 统一 CLI 入口为 lyxy_document_reader.py
- 统一 Markdown 后处理逻辑
- 按文件类型组织 readers,每个解析器独立文件
- 依赖分组按文件类型细分(docx、xlsx、pptx、pdf、html、http)
- PDF OCR 解析器优先,无参数控制
- 使用 logging 模块替代简单 print
- 设计完整的单元测试结构
- 重写项目文档

## 新增目录/文件

- core/ - 核心模块(异常体系、Markdown 工具、解析调度器)
- readers/ - 格式阅读器(base.py + docx/xlsx/pptx/pdf/html)
- utils/ - 工具函数(文件类型检测)
- tests/ - 测试(conftest.py + test_core/ + test_readers/ + test_utils/)
- lyxy_document_reader.py - 统一 CLI 入口

## 依赖分组

- docx - DOCX 文档解析支持
- xlsx - XLSX 文档解析支持
- pptx - PPTX 文档解析支持
- pdf - PDF 文档解析支持(含 OCR)
- html - HTML/URL 解析支持
- http - HTTP/URL 下载支持
- office - Office 格式组合(docx/xlsx/pptx/pdf)
- web - Web 格式组合(html/http)
- full - 完整功能
- dev - 开发依赖
This commit is contained in:
2026-03-08 13:46:37 +08:00
parent eb8973495e
commit 833018d451
66 changed files with 4054 additions and 0 deletions

View File

@@ -0,0 +1,81 @@
## 1. 项目基础架构
- [x] 1.1 创建目录结构core/、readers/、utils/、tests/
- [x] 1.2 更新 pyproject.toml添加所有依赖分组
- [x] 1.3 创建 core/exceptions.py实现自定义异常体系
- [x] 1.4 创建 readers/base.py实现 Reader 基类
## 2. 核心模块
- [x] 2.1 创建 core/markdown.py迁移 Markdown 后处理函数
- [x] 2.2 创建 utils/file_detection.py实现输入类型检测
- [x] 2.3 创建 core/parser.py实现统一解析调度器
- [x] 2.4 创建 readers/__init__.py显式注册所有 reader
## 3. DOCX Reader
- [x] 3.1 创建 readers/docx/ 目录结构和 __init__.py
- [x] 3.2 创建 readers/docx/docling.py
- [x] 3.3 创建 readers/docx/unstructured.py
- [x] 3.4 创建 readers/docx/markitdown.py
- [x] 3.5 创建 readers/docx/pypandoc.py
- [x] 3.6 创建 readers/docx/python_docx.py
- [x] 3.7 创建 readers/docx/native_xml.py
## 4. XLSX Reader
- [x] 4.1 创建 readers/xlsx/ 目录结构和 __init__.py
- [x] 4.2 创建 readers/xlsx/docling.py
- [x] 4.3 创建 readers/xlsx/unstructured.py
- [x] 4.4 创建 readers/xlsx/markitdown.py
- [x] 4.5 创建 readers/xlsx/pandas.py
- [x] 4.6 创建 readers/xlsx/native_xml.py
## 5. PPTX Reader
- [x] 5.1 创建 readers/pptx/ 目录结构和 __init__.py
- [x] 5.2 创建 readers/pptx/docling.py
- [x] 5.3 创建 readers/pptx/unstructured.py
- [x] 5.4 创建 readers/pptx/markitdown.py
- [x] 5.5 创建 readers/pptx/python_pptx.py
- [x] 5.6 创建 readers/pptx/native_xml.py
## 6. PDF Reader
- [x] 6.1 创建 readers/pdf/ 目录结构和 __init__.py
- [x] 6.2 创建 readers/pdf/docling_ocr.py
- [x] 6.3 创建 readers/pdf/unstructured_ocr.py
- [x] 6.4 创建 readers/pdf/docling.py
- [x] 6.5 创建 readers/pdf/unstructured.py
- [x] 6.6 创建 readers/pdf/markitdown.py
- [x] 6.7 创建 readers/pdf/pypdf.py
## 7. HTML Reader
- [x] 7.1 创建 readers/html/ 目录结构和 __init__.py
- [x] 7.2 创建 readers/html/downloader.py迁移 URL 下载器
- [x] 7.3 创建 readers/html/cleaner.py迁移 HTML 清理器
- [x] 7.4 创建 readers/html/trafilatura.py
- [x] 7.5 创建 readers/html/domscribe.py
- [x] 7.6 创建 readers/html/markitdown.py
- [x] 7.7 创建 readers/html/html2text.py
## 8. 统一 CLI 入口
- [x] 8.1 创建 lyxy_document_reader.py实现统一 CLI
- [x] 8.2 集成 logging 模块
## 9. 测试
- [x] 9.1 创建 tests/conftest.py
- [x] 9.2 创建 tests/test_core/,测试核心模块
- [x] 9.3 创建 tests/test_readers/test_docx/
- [x] 9.4 创建 tests/test_readers/test_xlsx/
- [x] 9.5 创建 tests/test_readers/test_pptx/
- [x] 9.6 创建 tests/test_readers/test_pdf/
- [x] 9.7 创建 tests/test_readers/test_html/
- [x] 9.8 创建 tests/test_utils/,测试工具函数
## 10. 文档
- [x] 10.1 重写 README.md