Skip to main content

论文格式自动化处理工具

Project description

WordFormat

论文格式自动化处理工具

License Python PyPI Platform Downloads

项目简介

WordFormat 是一个基于 Python 开发的 Word 文档自动化格式检查与修正工具,专为学术论文(本科/硕士/博士毕业论文、期刊论文等)的格式合规性审查设计。该工具能够智能解析 Word 文档结构,识别标题、摘要、正文、参考文献等不同段落类型,并依据自定义的格式规范自动校验文档格式,支持在违规位置添加批注或直接修正格式问题,大幅提升论文格式审核效率。

功能特性

核心能力

  • 智能文档结构解析:基于 ONNX 模型自动识别文档中的标题、摘要、正文、关键词、参考文献等段落类型,生成结构化 JSON 配置文件
  • 精细化格式校验:支持段落格式(对齐、行距、缩进、段间距)和字符格式(字体、字号、颜色、加粗/斜体/下划线)的全维度检查
  • 多级别标题管理:精准识别一级/二级/三级标题,支持自定义标题格式规范校验
  • 多语言适配:区分中英文字体/格式规则,完美支持中英文混合文档的格式检查
  • 灵活的交互方式:支持「生成结构文件→手动调整→执行校验」的分步流程,兼顾自动化与灵活性

实用功能

  • 自动批注生成:在格式违规位置自动添加 Word 批注,标注问题类型和修正建议
  • 文档结构可视化:通过 wordf tree 命令以树形结构展示文档段落分类和层级关系,支持按类别过滤、显示置信度
  • 格式一键修正:支持根据规范自动修正部分常见格式问题(如标题字号、正文行距)
  • 标题自动编号:支持自动清除手动编号并应用 Word 自动编号,可自定义编号模板(如"第X章"、"1.1.1")、编号后缀(制表符/空格/无)和缩进设置
  • Web 可视化界面:内置 Vue 前端界面,通过 wordf startapi 一键启动图形化操作面板,告别命令行
  • 自定义配置:通过 YAML 配置文件灵活定义格式规范,适配不同学校/期刊的格式要求
  • 跨平台兼容:支持 Windows/macOS/Linux 系统,基于 python-docx 实现跨平台 Word 文档处理

视频教程

点击直达B站视频

快速开始

环境要求

  • Python 3.10+(推荐 3.11 及以上版本)
  • 依赖管理工具:uv(推荐)或 pip

安装步骤

方式一:pipx 安装(强烈推荐)

pipx 会自动隔离环境并注册命令,安装完就能用,不会有 PATH 问题。

# 安装 pipx(如果还没有)
brew install pipx        # macOS
pip install pipx         # 其他平台

# 安装 WordFormat
pipx install wordformat

# 需要 Web 界面时安装 api 版本
pipx install "wordformat[api]"

安装完成后直接使用 wordfwordformat 命令。

方式二:pip 安装

pip install wordformat
# 或
pip install "wordformat[api]"

安装后如果提示"找不到 wordf 命令",说明 Python 脚本目录不在系统 PATH 中。 请改用 python3 -m wordformat 替代,或改用 pipx 安装。

方式三:从源码安装(开发者)

  1. 克隆项目

    git clone https://github.com/AfishInLake/WordFormat.git
    cd WordFormat
    
  2. 安装依赖

    make install
    # 或使用 pip
    pip install -e .
    
  3. 下载模型

    python scripts/download_model.py
    

核心使用方法

命令行使用(推荐)

WordFormat 提供三种核心执行模式:

# 0. 生成配置模板
wordf config -o 配置.yaml

# 1. 生成文档结构 JSON
wordf gj -d 论文.docx -c 配置.yaml

# 2. 查看文档结构树(检查分类是否正确)
wordf tree -f 结构文件.json

# 3. 执行格式校验(添加批注,不修改原文)
wordf cf -d 论文.docx -c 配置.yaml -f 结构文件.json

# 4. 执行自动格式化(一键修正格式)
wordf af -d 论文.docx -c 配置.yaml -f 结构文件.json

# 5. 启动 Web 可视化界面
wordf startapi
# 然后在浏览器打开 http://127.0.0.1:8000

startapi命令行预览(推荐使用)

# 下载api版
pip install "wordformat[api]"
# 启动 Web 可视化界面
wordf startapi
# 访问 http://127.0.0.1:8000

# 若提示无法找到 wordf 命令,请改用 pipx 安装
# 或直接使用:
python3 -m wordformat startapi
  • 推荐使用.bat实现快速启动 在桌面创建start.txt文件,写入下列命令(点击复制即可),修改后缀为.bat(完整文件名称start.bat),双击即可启动
python -m wordformat startapi

配置界面

配置界面预览

格式化操作界面

格式化操作界面预览

更多详细用法请查看 使用指南

AI Skill 集成

WordFormat 提供了 SOLO Skill,可在 SOLO 等 AI 助手平台中直接调用,实现对话式论文格式化。

Skill 工作流程

Skill 包含两个独立任务,可分步执行:

任务 说明 产物
任务一:准备配置文件 根据格式要求生成/编辑 config.yaml config.yaml
任务二:执行格式化 使用配置文件对论文进行格式检查或修正 --标注版.docx--修改版.docx

Skill 目录结构

wordformat-skill/
├── SKILL.md                    # Skill 定义文件
├── scripts/
│   ├── setup_config.py         # 配置文件生成/验证脚本
│   ├── validate_json.py        # JSON 标签校验脚本
│   └── validate_config.py      # 配置文件验证脚本
└── data/
    ├── config.yaml             # 默认配置模板
    ├── config_spec.md          # 配置文件完整字段规范
    ├── config_editing_guide.md # 配置编辑指南
    ├── category_reference.md   # 段落分类参考
    └── font_size_table.md      # 字号对照表

预设配置库

项目内置了多所高校的论文格式预设,保存在 presets/ 目录下,命名格式为 {学校}_{学院/专业}_{论文类型}.yaml,可直接使用或在此基础上修改。

详细文档

更多详细文档请查看 docs/ 目录:

许可证

Apache License 2.0 - 允许自由使用、修改和分发,需保留原作者声明。

联系方式

  • 反馈渠道:GitHub Issues(优先推荐,方便问题跟踪和交流)
  • 联系邮箱:1593699665@qq.com

项目贡献者

待补充,欢迎各位开发者提交PR贡献代码,一起完善这个工具!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wordformat-1.4.0.tar.gz (66.2 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wordformat-1.4.0-py3-none-any.whl (66.3 MB view details)

Uploaded Python 3

File details

Details for the file wordformat-1.4.0.tar.gz.

File metadata

  • Download URL: wordformat-1.4.0.tar.gz
  • Upload date:
  • Size: 66.2 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for wordformat-1.4.0.tar.gz
Algorithm Hash digest
SHA256 adb7fee4047d6c9fe6dbcfbb63e1bdd26882eb3874a15bc10adff60f8c150fe6
MD5 8aacb2d8fbcb313293e0249fe270b47f
BLAKE2b-256 e68ba8aa7d267318a525b50ddce8dded58f7e437421b1606da46a5026f5a97fb

See more details on using hashes here.

Provenance

The following attestation bundles were made for wordformat-1.4.0.tar.gz:

Publisher: ci.yml on AfishInLake/WordFormat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file wordformat-1.4.0-py3-none-any.whl.

File metadata

  • Download URL: wordformat-1.4.0-py3-none-any.whl
  • Upload date:
  • Size: 66.3 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for wordformat-1.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cb7acc93f768483dd2cc71f79d88ed3dfa8a8da19ec1406539e3a88137fd274b
MD5 29b918347db0f34d92368b15d8834fd3
BLAKE2b-256 ab9576bd2730df8f6b19fbca63faff60403874bc67b6d1cb3d6187a3fc13dd01

See more details on using hashes here.

Provenance

The following attestation bundles were made for wordformat-1.4.0-py3-none-any.whl:

Publisher: ci.yml on AfishInLake/WordFormat

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page