# docx_parsing_demo **Repository Path**: dplearning/docx_parsing_demo ## Basic Information - **Project Name**: docx_parsing_demo - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-09-15 - **Last Updated**: 2026-09-15 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Word 实验报告解析工具 将有机材料合成实验报告(`.docx` / `.doc` / `.wps`)解析为结构化 JSON。 **流程:** `.doc`或`.wps` → `.docx` → Markdown → VLM 图片识别 → LLM 结构化提取 → JSON --- ## 安装 ### 1. 创建 Python 虚拟环境 ```bash python -m venv .venv source .venv/bin/activate # Linux / macOS # .venv\Scripts\activate # Windows pip install -r requirements.txt ``` ### 2. 安装外部软件 | 软件 | 用途 | 安装方式 | |------|------|---------| | **Pandoc** | 文档转 Markdown | `sudo apt install pandoc` / `brew install pandoc` / [官网下载](https://pandoc.org/installing.html) | | **Inkscape** | 矢量图转 PNG | `sudo apt install inkscape` / `brew install inkscape` / [官网下载](https://inkscape.org/) | | **LibreOffice** 或 **WPS Office** | 旧版 `.doc` 转 `.docx` | 非必需,仅在输入 `.doc` 文件时需要 | ### 3. 配置环境变量 ```bash cp .env.example .env ``` 编辑 `.env`,填入你的大模型 API 地址和密钥: ```bash LLM_BASE_URL=http://your-api.com/v1 LLM_MODEL=your-model-name LLM_API_KEY=your-api-key ``` - `LLM_*`:主模型(需支持工具调用),用于从 Markdown 提取 JSON - `VLM_*`:视觉模型(可选,不填则与 LLM 共用),用于图片识别 --- ## 使用 ### 解析文档 ```bash python docx_parser.py input.docx ``` 输出自动生成到 `output_as2.0/<文件名>/<时间戳>/output.json`。 指定输出路径: ```bash python docx_parser.py input.docx output/output.json ``` 支持 `.docx`、`.doc`、`.wps` 三种格式。允许图片识别失败时继续: ```bash python docx_parser.py input.docx --allow-image-errors ``` ### 生成 HTML ```bash python generate_html.py output/output.json ``` ### Web 问答 ```bash uvicorn web_app:app --host 127.0.0.1 --port 8000 ``` 访问 http://127.0.0.1:8000 ### 命令行问答 ```bash python query.py ```