Skip to content

支持在不进行本地编译的情况下计算文本数量#480

Merged
TheNetAdmin merged 1 commit into
TheNetAdmin:masterfrom
Littleor:master
Dec 8, 2025
Merged

支持在不进行本地编译的情况下计算文本数量#480
TheNetAdmin merged 1 commit into
TheNetAdmin:masterfrom
Littleor:master

Conversation

@Littleor

Copy link
Copy Markdown
Contributor

现有文本统计依赖于两种方案:

  1. Overleaf 统计,但是受到该问题影响导致无法正常统计
  2. 本地编译后使用 texcount 统计,但这依赖于本地预先 latexmk 编译,对于使用 Overleaf 的用户来说还需要配置本地环境

因此新增了一个 Python 脚本用于统计某个 .tex 文件及其引入的子 .tex文件的总字数,避免了复杂的配置,用法如下:

# python script/count_tex_words.py [tex 文件地址] --max-depth [最大统计的子文件深度]
# 下行为统计硕士毕业论文正文文本数量的案例;本科/博士替换为对应的 content.tex 即可
python script/count_tex_words.py body/graduate/content.tex 

结果如下:

git:(main*) $ python script/count_tex_words.py body/graduate/content.tex  --max-depth 1

Word Count Tree Structure:
body/graduate/content.tex (CN: 0, EN: 0, Total: 0)
├── body/graduate/01_intro.tex (CN: 5798, EN: 58, Total: 5856)
├── body/graduate/02_related_work.tex (CN: 7882, EN: 183, Total: 8065)
├── body/graduate/03_*****.tex (CN: 8572, EN: 424, Total: 8996)
├── body/graduate/04_*****..tex (CN: 7830, EN: 244, Total: 8074)
├── body/graduate/05_*****..tex (CN: 0, EN: 0, Total: 0)
└── body/graduate/06_conclusion.tex (CN: 2245, EN: 2, Total: 2247)
------------------------------------------------------------
GRAND TOTAL: CN: 33057, EN: 1811, Total: 34868

@TheNetAdmin TheNetAdmin merged commit 1e531b9 into TheNetAdmin:master Dec 8, 2025
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants