Skip to content

fpGHwd/wccn

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Chinese Word Count

A Python package for counting Chinese characters in text files.

Installation

pip install wccn

Or install from source:

git clone https://github.com/fpGHwd/wccn.git
cd wccn
pip install -e .

Usage

As a command-line tool

# After installation
wccn.py ~/Documents/org 3 .org

# Or using the original script
python wccn.py ~/Documents/org 3 .org

As a Python package

from chinese_wordcount.counter import count_file, walk

# Count Chinese characters in a file
count = count_file('path/to/your/file.txt')
print(f"Chinese character count: {count}")

# Walk through directories
for directory, subdirs, files in walk('path/to/directory', depth=3):
    for file in files:
        if file.endswith('.txt'):
            full_path = f"{directory}/{file}"
            count = count_file(full_path)
            print(f"{count}\t{full_path}")

License

MIT

readme org version

  • Description:
  • 统计文档中的中文字数,默认 utf-8 编码
  • count all chinese characters in a directory with specific file extension appendix and specific depth of search
  • Usage:
  • =python chinese_wc.py [directory] [depth] [file extension appendix]=
  • Example:
  • =python chinese_wc.py "/home/wd/Documents/org" 4 ".org"=
  • =python chinese_wc.py ~/Documents/org 4 '.org'=

About

count text file chinese character(utf8) number

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages