Skip to content

Latest commit

 

History

31 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

auto_tab

可复用的 Word 表格填写系统。解包 → 去重 → 扫描标签 → 填表 → 还原 → 打包,全程只读原文档。

安装

git clone https://github.com/shortFisherman/auto_tab.git
cd auto_tab
pip install -r requirements.txt

依赖:Python 3.10+、lxml、defusedxml、openai、python-dotenv。无需 Word 应用程序。

快速开始

# 一条命令:AI 自动填表
python -m src auto documents/6.docx info/6.md --output results/6.docx

AI 会根据 Markdown 信息文档自动匹配表单标签。原则:可精简不可新增 — 日期格式可以适配,但绝不编造信息。

使用

AI 自动填写(推荐)

python -m src auto documents/模板.docx info/信息.md --output results/结果.docx

程序自动完成:解包 → 去重 → 扫描标签 → AI 填写 → 打包。一步到位。

AI 会根据 Markdown 信息文档的内容自动匹配表单标签。原则:可精简不可新增 — 日期格式可以适配,但绝不编造信息。

配置文件 .env(项目根目录):

AI_API_KEY=sk-xxx                                   # API Key
AI_BASE_URL=https://api.deepseek.com                 # API 地址,默认 DeepSeek
AI_MODEL=deepseek-chat                              # 模型名称

兼容 DeepSeek、OpenAI、Ollama 等任何 OpenAI 兼容 API。

手动三步(高级用法)

# 1. 准备:生成字典模板
python -m src prepare documents/模板.docx --output dicts/模板.json

# 2. 打开 dicts/模板.json,把空值填上

# 3. 运行:填表 → 打包
python -m src run dicts/模板.json documents/模板.docx results/结果.docx

命令

python -m src auto <input.docx> <info.md> --output <output.docx> [-q]       # 一条龙
python -m src prepare <input.docx> [--output <dict.json>] [-q]              # 生成模板
python -m src run <dict.json> <input.docx> <output.docx> [-q]                # 填表打包

-q / --quiet 隐藏逐格填写日志。

字典格式

{
    "normal": {
        "姓名": "江月",
        "性别": ""
    },
    "header_tables": [
        {
            "headers": ["学校", "起止时间", "是否最高学历"],
            "data": [
                ["安庆一中", "2010-09/2013-06", ""],
                ["合肥工大", "2013-09/2017-06", ""]
            ]
        }
    ]
}

项目结构

├── src/
│   ├── pipeline.py          ← 编排层
│   ├── dedup.py             ← 重复文本处理
│   ├── scanner.py           ← 标签扫描
│   ├── fill.py              ← 填表引擎
│   ├── ai_fill_template.py  ← AI 自动填表
│   ├── _xml_utils.py        ← XML 工具
│   ├── cli.py               ← CLI 入口
│   └── _office/             ← 解包/打包(自包含)
├── dicts/                   ← 字典模板 + 填写结果
├── documents/               ← 原始 .docx 模板
├── info/                    ← Markdown 信息文档
├── results/                 ← 填表输出的 .docx
└── .cache/                  ← 临时缓存(自动清理)

License

MIT

About

可复用的 Word 表格填写系统。解包 → 去重 → 扫描标签 → 填表 → 还原 → 打包,全程只读原文档。支持 AI 自动填写。

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages