wordformat 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wordformat-1.0.0/LICENSE +201 -0
- wordformat-1.0.0/PKG-INFO +166 -0
- wordformat-1.0.0/README.md +115 -0
- wordformat-1.0.0/pyproject.toml +139 -0
- wordformat-1.0.0/setup.cfg +4 -0
- wordformat-1.0.0/src/wordformat/__init__.py +11 -0
- wordformat-1.0.0/src/wordformat/agent/__init__.py +4 -0
- wordformat-1.0.0/src/wordformat/agent/message.py +79 -0
- wordformat-1.0.0/src/wordformat/agent/onnx_infer.py +261 -0
- wordformat-1.0.0/src/wordformat/api/__init__.py +269 -0
- wordformat-1.0.0/src/wordformat/base.py +85 -0
- wordformat-1.0.0/src/wordformat/cli.py +184 -0
- wordformat-1.0.0/src/wordformat/config/__init__.py +4 -0
- wordformat-1.0.0/src/wordformat/config/config.py +112 -0
- wordformat-1.0.0/src/wordformat/config/datamodel.py +288 -0
- wordformat-1.0.0/src/wordformat/data/model/id2label.json +17 -0
- wordformat-1.0.0/src/wordformat/data/model/label2id.json +17 -0
- wordformat-1.0.0/src/wordformat/data/model/tokenizer.json +21283 -0
- wordformat-1.0.0/src/wordformat/data/system_prompt.txt +41 -0
- wordformat-1.0.0/src/wordformat/log_config.py +83 -0
- wordformat-1.0.0/src/wordformat/rules/__init__.py +42 -0
- wordformat-1.0.0/src/wordformat/rules/abstract.py +288 -0
- wordformat-1.0.0/src/wordformat/rules/acknowledgement.py +114 -0
- wordformat-1.0.0/src/wordformat/rules/body.py +59 -0
- wordformat-1.0.0/src/wordformat/rules/caption.py +100 -0
- wordformat-1.0.0/src/wordformat/rules/heading.py +154 -0
- wordformat-1.0.0/src/wordformat/rules/keywords.py +266 -0
- wordformat-1.0.0/src/wordformat/rules/node.py +181 -0
- wordformat-1.0.0/src/wordformat/rules/references.py +100 -0
- wordformat-1.0.0/src/wordformat/set_style.py +177 -0
- wordformat-1.0.0/src/wordformat/set_tag.py +22 -0
- wordformat-1.0.0/src/wordformat/settings.py +33 -0
- wordformat-1.0.0/src/wordformat/style/__init__.py +4 -0
- wordformat-1.0.0/src/wordformat/style/check_format.py +530 -0
- wordformat-1.0.0/src/wordformat/style/get_some.py +443 -0
- wordformat-1.0.0/src/wordformat/style/set_some.py +527 -0
- wordformat-1.0.0/src/wordformat/style/style_enum.py +603 -0
- wordformat-1.0.0/src/wordformat/style/utils.py +140 -0
- wordformat-1.0.0/src/wordformat/tree.py +178 -0
- wordformat-1.0.0/src/wordformat/utils.py +128 -0
- wordformat-1.0.0/src/wordformat/word_structure/__init__.py +4 -0
- wordformat-1.0.0/src/wordformat/word_structure/document_builder.py +38 -0
- wordformat-1.0.0/src/wordformat/word_structure/node_factory.py +30 -0
- wordformat-1.0.0/src/wordformat/word_structure/settings.py +56 -0
- wordformat-1.0.0/src/wordformat/word_structure/tree_builder.py +77 -0
- wordformat-1.0.0/src/wordformat/word_structure/utils.py +62 -0
- wordformat-1.0.0/src/wordformat.egg-info/PKG-INFO +166 -0
- wordformat-1.0.0/src/wordformat.egg-info/SOURCES.txt +57 -0
- wordformat-1.0.0/src/wordformat.egg-info/dependency_links.txt +1 -0
- wordformat-1.0.0/src/wordformat.egg-info/entry_points.txt +3 -0
- wordformat-1.0.0/src/wordformat.egg-info/requires.txt +27 -0
- wordformat-1.0.0/src/wordformat.egg-info/top_level.txt +1 -0
- wordformat-1.0.0/tests/test_base.py +162 -0
- wordformat-1.0.0/tests/test_cli.py +230 -0
- wordformat-1.0.0/tests/test_node.py +226 -0
- wordformat-1.0.0/tests/test_set_style.py +332 -0
- wordformat-1.0.0/tests/test_set_tag.py +33 -0
- wordformat-1.0.0/tests/test_tree.py +162 -0
- wordformat-1.0.0/tests/test_utils.py +113 -0
wordformat-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 afish
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: wordformat
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: 论文格式自动化处理工具
|
|
5
|
+
Author-email: afish <1593699665@qq.com>
|
|
6
|
+
License-Expression: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://github.com/AfishInLake/WordFormat
|
|
8
|
+
Project-URL: Repository, https://github.com/AfishInLake/WordFormat
|
|
9
|
+
Project-URL: Bug Tracker, https://github.com/AfishInLake/WordFormat/issues
|
|
10
|
+
Keywords: word,docx,thesis,format,论文,格式,校验,自动化
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Intended Audience :: Education
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Scientific/Engineering
|
|
21
|
+
Classifier: Topic :: Text Processing
|
|
22
|
+
Classifier: Operating System :: OS Independent
|
|
23
|
+
Requires-Python: >=3.10
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
License-File: LICENSE
|
|
26
|
+
Requires-Dist: loguru>=0.7.3
|
|
27
|
+
Requires-Dist: numpy>=1.24.0
|
|
28
|
+
Requires-Dist: onnxruntime>=1.17.0
|
|
29
|
+
Requires-Dist: pydantic>=2.12.5
|
|
30
|
+
Requires-Dist: python-docx>=1.2.0
|
|
31
|
+
Requires-Dist: python-dotenv>=1.2.1
|
|
32
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
33
|
+
Requires-Dist: requests>=2.32.5
|
|
34
|
+
Requires-Dist: tenacity>=9.1.2
|
|
35
|
+
Requires-Dist: tokenizers>=0.22.2
|
|
36
|
+
Requires-Dist: webcolors>=25.10.0
|
|
37
|
+
Provides-Extra: api
|
|
38
|
+
Requires-Dist: fastapi>=0.128.1; extra == "api"
|
|
39
|
+
Requires-Dist: uvicorn>=0.40.0; extra == "api"
|
|
40
|
+
Requires-Dist: python-multipart>=0.0.22; extra == "api"
|
|
41
|
+
Provides-Extra: test
|
|
42
|
+
Requires-Dist: pytest>=9.0.2; extra == "test"
|
|
43
|
+
Requires-Dist: pytest-asyncio>=1.3.0; extra == "test"
|
|
44
|
+
Requires-Dist: pytest-cov>=7.0.0; extra == "test"
|
|
45
|
+
Provides-Extra: dev
|
|
46
|
+
Requires-Dist: wordformat[api,test]; extra == "dev"
|
|
47
|
+
Requires-Dist: pre-commit>=4.5.1; extra == "dev"
|
|
48
|
+
Requires-Dist: ruff>=0.14.14; extra == "dev"
|
|
49
|
+
Requires-Dist: pyinstaller>=6.18.0; extra == "dev"
|
|
50
|
+
Dynamic: license-file
|
|
51
|
+
|
|
52
|
+
# WordFormat
|
|
53
|
+
|
|
54
|
+
> 论文格式自动化处理工具
|
|
55
|
+
|
|
56
|
+

|
|
57
|
+

|
|
58
|
+

|
|
59
|
+

|
|
60
|
+
|
|
61
|
+
## 项目简介
|
|
62
|
+
|
|
63
|
+
**WordFormat** 是一个基于 Python 开发的 Word 文档自动化格式检查与修正工具,专为学术论文(本科/硕士/博士毕业论文、期刊论文等)的格式合规性审查设计。该工具能够智能解析 Word 文档结构,识别标题、摘要、正文、参考文献等不同段落类型,并依据自定义的格式规范自动校验文档格式,支持在违规位置添加批注或直接修正格式问题,大幅提升论文格式审核效率。
|
|
64
|
+
|
|
65
|
+
点击 **[WordFormatUI](https://github.com/AfishInLake/WordFormatUI)** 查看带有GUI界面的项目
|
|
66
|
+
## 功能特性
|
|
67
|
+
|
|
68
|
+
### 核心能力
|
|
69
|
+
- **智能文档结构解析**:基于 ONNX 模型自动识别文档中的标题、摘要、正文、关键词、参考文献等段落类型,生成结构化 JSON 配置文件
|
|
70
|
+
- **精细化格式校验**:支持段落格式(对齐、行距、缩进、段间距)和字符格式(字体、字号、颜色、加粗/斜体/下划线)的全维度检查
|
|
71
|
+
- **多级别标题管理**:精准识别一级/二级/三级标题,支持自定义标题格式规范校验
|
|
72
|
+
- **多语言适配**:区分中英文字体/格式规则,完美支持中英文混合文档的格式检查
|
|
73
|
+
- **灵活的交互方式**:支持「生成结构文件→手动调整→执行校验」的分步流程,兼顾自动化与灵活性
|
|
74
|
+
|
|
75
|
+
### 实用功能
|
|
76
|
+
- **自动批注生成**:在格式违规位置自动添加 Word 批注,标注问题类型和修正建议
|
|
77
|
+
- **格式一键修正**:支持根据规范自动修正部分常见格式问题(如标题字号、正文行距)
|
|
78
|
+
- **自定义配置**:通过 YAML 配置文件灵活定义格式规范,适配不同学校/期刊的格式要求
|
|
79
|
+
- **跨平台兼容**:支持 Windows/macOS/Linux 系统,基于 python-docx 实现跨平台 Word 文档处理
|
|
80
|
+
|
|
81
|
+
## 视频教程
|
|
82
|
+
[点击直达B站视频](https://www.bilibili.com/video/BV1aiDjB8Edg/?spm_id_from=333.1007.top_right_bar_window_history.content.click&vd_source=490c514f59611dc0b600c1da58948e14)
|
|
83
|
+
|
|
84
|
+
## 普通用户请看这里
|
|
85
|
+
+ 如果你是普通用户,请点击[WordFormatUI](https://github.com/AfishInLake/WordFormatUI/releases)下载带有GUI界面的安装包直接使用,并参考[安装指南](https://github.com/AfishInLake/WordFormatUI/blob/master/README.md)进行安装。
|
|
86
|
+
+ 如果你是开发人员,请按照以下步骤进行安装和运行
|
|
87
|
+
|
|
88
|
+
## 快速开始
|
|
89
|
+
|
|
90
|
+
### 环境要求
|
|
91
|
+
- Python 3.10+(推荐 3.11 及以上版本)
|
|
92
|
+
- 依赖管理工具:uv(推荐)或 pip
|
|
93
|
+
|
|
94
|
+
### 安装步骤
|
|
95
|
+
|
|
96
|
+
1. **克隆项目**
|
|
97
|
+
```bash
|
|
98
|
+
git clone https://github.com/AfishInLake/WordFormat.git
|
|
99
|
+
cd WordFormat
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
2. **安装依赖**
|
|
103
|
+
```bash
|
|
104
|
+
make install
|
|
105
|
+
# 或使用 pip
|
|
106
|
+
pip install -e .
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
3. **配置环境变量**
|
|
110
|
+
创建 `.env` 文件,配置 HOST、PORT 等必要参数:
|
|
111
|
+
```env
|
|
112
|
+
HOST="127.0.0.1"
|
|
113
|
+
# 配置服务端口
|
|
114
|
+
PORT="8000"
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
4. **启动API服务**
|
|
118
|
+
```bash
|
|
119
|
+
# 在虚拟环境下运行
|
|
120
|
+
make server
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
5. **构建.exe程序**
|
|
124
|
+
```bash
|
|
125
|
+
# 在虚拟环境下运行
|
|
126
|
+
make build
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## 核心使用方法
|
|
130
|
+
|
|
131
|
+
### 命令行使用(推荐)
|
|
132
|
+
|
|
133
|
+
WordFormat 提供三种核心执行模式:
|
|
134
|
+
|
|
135
|
+
1. **生成文档结构 JSON**
|
|
136
|
+
|
|
137
|
+
2. **执行格式校验**
|
|
138
|
+
|
|
139
|
+
3. **执行格式格式化**
|
|
140
|
+
|
|
141
|
+
具体请看
|
|
142
|
+
- [使用指南](docs/usage.md)
|
|
143
|
+
|
|
144
|
+
## 详细文档
|
|
145
|
+
|
|
146
|
+
更多详细文档请查看 `docs/` 目录:
|
|
147
|
+
|
|
148
|
+
- [安装指南](docs/installation.md) - 环境要求和安装步骤
|
|
149
|
+
- [使用指南](docs/usage.md) - 命令行、Python编程和API调用的详细使用方法
|
|
150
|
+
- [配置文件说明](docs/configuration.md) - 格式规范配置项和自定义配置方法
|
|
151
|
+
- [常见问题](docs/faq.md) - 常见问题及解决方案
|
|
152
|
+
- [贡献指南](docs/contributing.md) - 如何为项目贡献代码和文档
|
|
153
|
+
- [技术架构](docs/architecture.md) - 项目的技术架构和实现原理
|
|
154
|
+
|
|
155
|
+
## 许可证
|
|
156
|
+
|
|
157
|
+
[Apache License 2.0](LICENSE) - 允许自由使用、修改和分发,需保留原作者声明。
|
|
158
|
+
|
|
159
|
+
## 联系方式
|
|
160
|
+
|
|
161
|
+
- 反馈渠道:GitHub Issues(优先推荐,方便问题跟踪和交流)
|
|
162
|
+
- 联系邮箱:1593699665@qq.com
|
|
163
|
+
|
|
164
|
+
## 项目贡献者
|
|
165
|
+
|
|
166
|
+
待补充,欢迎各位开发者提交PR贡献代码,一起完善这个工具!
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
# WordFormat
|
|
2
|
+
|
|
3
|
+
> 论文格式自动化处理工具
|
|
4
|
+
|
|
5
|
+

|
|
6
|
+

|
|
7
|
+

|
|
8
|
+

|
|
9
|
+
|
|
10
|
+
## 项目简介
|
|
11
|
+
|
|
12
|
+
**WordFormat** 是一个基于 Python 开发的 Word 文档自动化格式检查与修正工具,专为学术论文(本科/硕士/博士毕业论文、期刊论文等)的格式合规性审查设计。该工具能够智能解析 Word 文档结构,识别标题、摘要、正文、参考文献等不同段落类型,并依据自定义的格式规范自动校验文档格式,支持在违规位置添加批注或直接修正格式问题,大幅提升论文格式审核效率。
|
|
13
|
+
|
|
14
|
+
点击 **[WordFormatUI](https://github.com/AfishInLake/WordFormatUI)** 查看带有GUI界面的项目
|
|
15
|
+
## 功能特性
|
|
16
|
+
|
|
17
|
+
### 核心能力
|
|
18
|
+
- **智能文档结构解析**:基于 ONNX 模型自动识别文档中的标题、摘要、正文、关键词、参考文献等段落类型,生成结构化 JSON 配置文件
|
|
19
|
+
- **精细化格式校验**:支持段落格式(对齐、行距、缩进、段间距)和字符格式(字体、字号、颜色、加粗/斜体/下划线)的全维度检查
|
|
20
|
+
- **多级别标题管理**:精准识别一级/二级/三级标题,支持自定义标题格式规范校验
|
|
21
|
+
- **多语言适配**:区分中英文字体/格式规则,完美支持中英文混合文档的格式检查
|
|
22
|
+
- **灵活的交互方式**:支持「生成结构文件→手动调整→执行校验」的分步流程,兼顾自动化与灵活性
|
|
23
|
+
|
|
24
|
+
### 实用功能
|
|
25
|
+
- **自动批注生成**:在格式违规位置自动添加 Word 批注,标注问题类型和修正建议
|
|
26
|
+
- **格式一键修正**:支持根据规范自动修正部分常见格式问题(如标题字号、正文行距)
|
|
27
|
+
- **自定义配置**:通过 YAML 配置文件灵活定义格式规范,适配不同学校/期刊的格式要求
|
|
28
|
+
- **跨平台兼容**:支持 Windows/macOS/Linux 系统,基于 python-docx 实现跨平台 Word 文档处理
|
|
29
|
+
|
|
30
|
+
## 视频教程
|
|
31
|
+
[点击直达B站视频](https://www.bilibili.com/video/BV1aiDjB8Edg/?spm_id_from=333.1007.top_right_bar_window_history.content.click&vd_source=490c514f59611dc0b600c1da58948e14)
|
|
32
|
+
|
|
33
|
+
## 普通用户请看这里
|
|
34
|
+
+ 如果你是普通用户,请点击[WordFormatUI](https://github.com/AfishInLake/WordFormatUI/releases)下载带有GUI界面的安装包直接使用,并参考[安装指南](https://github.com/AfishInLake/WordFormatUI/blob/master/README.md)进行安装。
|
|
35
|
+
+ 如果你是开发人员,请按照以下步骤进行安装和运行
|
|
36
|
+
|
|
37
|
+
## 快速开始
|
|
38
|
+
|
|
39
|
+
### 环境要求
|
|
40
|
+
- Python 3.10+(推荐 3.11 及以上版本)
|
|
41
|
+
- 依赖管理工具:uv(推荐)或 pip
|
|
42
|
+
|
|
43
|
+
### 安装步骤
|
|
44
|
+
|
|
45
|
+
1. **克隆项目**
|
|
46
|
+
```bash
|
|
47
|
+
git clone https://github.com/AfishInLake/WordFormat.git
|
|
48
|
+
cd WordFormat
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
2. **安装依赖**
|
|
52
|
+
```bash
|
|
53
|
+
make install
|
|
54
|
+
# 或使用 pip
|
|
55
|
+
pip install -e .
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
3. **配置环境变量**
|
|
59
|
+
创建 `.env` 文件,配置 HOST、PORT 等必要参数:
|
|
60
|
+
```env
|
|
61
|
+
HOST="127.0.0.1"
|
|
62
|
+
# 配置服务端口
|
|
63
|
+
PORT="8000"
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
4. **启动API服务**
|
|
67
|
+
```bash
|
|
68
|
+
# 在虚拟环境下运行
|
|
69
|
+
make server
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
5. **构建.exe程序**
|
|
73
|
+
```bash
|
|
74
|
+
# 在虚拟环境下运行
|
|
75
|
+
make build
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## 核心使用方法
|
|
79
|
+
|
|
80
|
+
### 命令行使用(推荐)
|
|
81
|
+
|
|
82
|
+
WordFormat 提供三种核心执行模式:
|
|
83
|
+
|
|
84
|
+
1. **生成文档结构 JSON**
|
|
85
|
+
|
|
86
|
+
2. **执行格式校验**
|
|
87
|
+
|
|
88
|
+
3. **执行格式格式化**
|
|
89
|
+
|
|
90
|
+
具体请看
|
|
91
|
+
- [使用指南](docs/usage.md)
|
|
92
|
+
|
|
93
|
+
## 详细文档
|
|
94
|
+
|
|
95
|
+
更多详细文档请查看 `docs/` 目录:
|
|
96
|
+
|
|
97
|
+
- [安装指南](docs/installation.md) - 环境要求和安装步骤
|
|
98
|
+
- [使用指南](docs/usage.md) - 命令行、Python编程和API调用的详细使用方法
|
|
99
|
+
- [配置文件说明](docs/configuration.md) - 格式规范配置项和自定义配置方法
|
|
100
|
+
- [常见问题](docs/faq.md) - 常见问题及解决方案
|
|
101
|
+
- [贡献指南](docs/contributing.md) - 如何为项目贡献代码和文档
|
|
102
|
+
- [技术架构](docs/architecture.md) - 项目的技术架构和实现原理
|
|
103
|
+
|
|
104
|
+
## 许可证
|
|
105
|
+
|
|
106
|
+
[Apache License 2.0](LICENSE) - 允许自由使用、修改和分发,需保留原作者声明。
|
|
107
|
+
|
|
108
|
+
## 联系方式
|
|
109
|
+
|
|
110
|
+
- 反馈渠道:GitHub Issues(优先推荐,方便问题跟踪和交流)
|
|
111
|
+
- 联系邮箱:1593699665@qq.com
|
|
112
|
+
|
|
113
|
+
## 项目贡献者
|
|
114
|
+
|
|
115
|
+
待补充,欢迎各位开发者提交PR贡献代码,一起完善这个工具!
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "wordformat"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "论文格式自动化处理工具"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "Apache-2.0"
|
|
7
|
+
requires-python = ">=3.10"
|
|
8
|
+
authors = [
|
|
9
|
+
{name = "afish", email = "1593699665@qq.com"},
|
|
10
|
+
]
|
|
11
|
+
keywords = ["word", "docx", "thesis", "format", "论文", "格式", "校验", "自动化"]
|
|
12
|
+
classifiers = [
|
|
13
|
+
"Development Status :: 3 - Alpha",
|
|
14
|
+
"Intended Audience :: Developers",
|
|
15
|
+
"Intended Audience :: Education",
|
|
16
|
+
"Intended Audience :: Science/Research",
|
|
17
|
+
"Programming Language :: Python :: 3",
|
|
18
|
+
"Programming Language :: Python :: 3.10",
|
|
19
|
+
"Programming Language :: Python :: 3.11",
|
|
20
|
+
"Programming Language :: Python :: 3.12",
|
|
21
|
+
"Programming Language :: Python :: 3.13",
|
|
22
|
+
"Topic :: Scientific/Engineering",
|
|
23
|
+
"Topic :: Text Processing",
|
|
24
|
+
"Operating System :: OS Independent",
|
|
25
|
+
]
|
|
26
|
+
dependencies = [
|
|
27
|
+
"loguru>=0.7.3",
|
|
28
|
+
"numpy>=1.24.0",
|
|
29
|
+
"onnxruntime>=1.17.0",
|
|
30
|
+
"pydantic>=2.12.5",
|
|
31
|
+
"python-docx>=1.2.0",
|
|
32
|
+
"python-dotenv>=1.2.1",
|
|
33
|
+
"pyyaml>=6.0.3",
|
|
34
|
+
"requests>=2.32.5",
|
|
35
|
+
"tenacity>=9.1.2",
|
|
36
|
+
"tokenizers>=0.22.2",
|
|
37
|
+
"webcolors>=25.10.0",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
[project.urls]
|
|
41
|
+
Homepage = "https://github.com/AfishInLake/WordFormat"
|
|
42
|
+
Repository = "https://github.com/AfishInLake/WordFormat"
|
|
43
|
+
"Bug Tracker" = "https://github.com/AfishInLake/WordFormat/issues"
|
|
44
|
+
|
|
45
|
+
[tool.ruff.lint]
|
|
46
|
+
select = [
|
|
47
|
+
"E", # pycodestyle errors
|
|
48
|
+
"W", # pycodestyle warnings
|
|
49
|
+
"F", # pyflakes
|
|
50
|
+
"I", # isort
|
|
51
|
+
"C", # flake8-comprehensions
|
|
52
|
+
"B", # flake8-bugbear
|
|
53
|
+
"T20", # flake8-print
|
|
54
|
+
"TC", # flake8-type-checking
|
|
55
|
+
"ASYNC", # flake8-asyncio
|
|
56
|
+
]
|
|
57
|
+
ignore = [
|
|
58
|
+
"ASYNC210",
|
|
59
|
+
"ASYNC251",
|
|
60
|
+
"ASYNC230",
|
|
61
|
+
"TC003",
|
|
62
|
+
"TC002"
|
|
63
|
+
]
|
|
64
|
+
fixable = ["A", "B", "C", "D", "E", "F", "G", "I", "N", "Q", "S", "T", "W", "ANN", "ARG", "BLE", "COM", "DJ", "DTZ", "EM", "ERA", "EXE", "FBT", "ICN", "INP", "ISC", "NPY", "PD", "PGH", "PIE", "PL", "PT", "PTH", "PYI", "RET", "RSE", "RUF", "SIM", "SLF", "TCH", "TID", "TRY", "UP", "YTT"]
|
|
65
|
+
unfixable = []
|
|
66
|
+
exclude = [
|
|
67
|
+
".bzr",
|
|
68
|
+
".direnv",
|
|
69
|
+
".eggs",
|
|
70
|
+
".git",
|
|
71
|
+
".hg",
|
|
72
|
+
".mypy_cache",
|
|
73
|
+
".nox",
|
|
74
|
+
".pants.d",
|
|
75
|
+
".pytype",
|
|
76
|
+
".ruff_cache",
|
|
77
|
+
".svn",
|
|
78
|
+
".tox",
|
|
79
|
+
".venv",
|
|
80
|
+
"__pypackages__",
|
|
81
|
+
"_build",
|
|
82
|
+
"buck-out",
|
|
83
|
+
"build",
|
|
84
|
+
"dist",
|
|
85
|
+
"node_modules",
|
|
86
|
+
"venv",
|
|
87
|
+
]
|
|
88
|
+
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"
|
|
89
|
+
|
|
90
|
+
[tool.ruff.lint.mccabe]
|
|
91
|
+
max-complexity = 10
|
|
92
|
+
|
|
93
|
+
[tool.ruff.lint.per-file-ignores]
|
|
94
|
+
"__init__.py" = ["F401", "F403", "E501"]
|
|
95
|
+
|
|
96
|
+
[tool.ruff.format]
|
|
97
|
+
quote-style = "double"
|
|
98
|
+
indent-style = "space"
|
|
99
|
+
skip-magic-trailing-comma = false
|
|
100
|
+
line-ending = "auto"
|
|
101
|
+
|
|
102
|
+
[tool.ruff.lint.pycodestyle]
|
|
103
|
+
max-line-length = 108
|
|
104
|
+
max-doc-length = 200
|
|
105
|
+
ignore-overlong-task-comments = true
|
|
106
|
+
|
|
107
|
+
[build-system]
|
|
108
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
109
|
+
build-backend = "setuptools.build_meta"
|
|
110
|
+
|
|
111
|
+
# 显式声明使用 src 布局(推荐)
|
|
112
|
+
[tool.setuptools.packages.find]
|
|
113
|
+
where = ["src"]
|
|
114
|
+
|
|
115
|
+
[tool.setuptools.package-data]
|
|
116
|
+
wordformat = ["data/**/*"]
|
|
117
|
+
|
|
118
|
+
[project.scripts]
|
|
119
|
+
wordformat = "wordformat.cli:main"
|
|
120
|
+
wf = "wordformat.cli:main"
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
[project.optional-dependencies]
|
|
124
|
+
api = [
|
|
125
|
+
"fastapi>=0.128.1",
|
|
126
|
+
"uvicorn>=0.40.0",
|
|
127
|
+
"python-multipart>=0.0.22",
|
|
128
|
+
]
|
|
129
|
+
test = [
|
|
130
|
+
"pytest>=9.0.2",
|
|
131
|
+
"pytest-asyncio>=1.3.0",
|
|
132
|
+
"pytest-cov>=7.0.0",
|
|
133
|
+
]
|
|
134
|
+
dev = [
|
|
135
|
+
"wordformat[test,api]",
|
|
136
|
+
"pre-commit>=4.5.1",
|
|
137
|
+
"ruff>=0.14.14",
|
|
138
|
+
"pyinstaller>=6.18.0",
|
|
139
|
+
]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#! /usr/bin/env python
|
|
2
|
+
# @Time : 2025/12/22 21:47
|
|
3
|
+
# @Author : afish
|
|
4
|
+
# @File : __init__.py.py
|
|
5
|
+
from wordformat.set_style import auto_format_thesis_document
|
|
6
|
+
from wordformat.set_tag import set_tag_main
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"auto_format_thesis_document",
|
|
10
|
+
"set_tag_main"
|
|
11
|
+
]
|