The script processes a Chinese interview text to segment words with jieba and generates a word cloud.
git clone https://github.com/sepinetam/wCloud.git
cd wCloud
python -m venv venv
source venv/bin/avtivate
pip install -r requirements.txt
- Modify/import txt text files into the in folder.
- Determine the font to use (default is SimHei).
- Run the script.
The example file is "in/example.txt"
.
The stop file is "stop.txt"
The returned file is "out/example.png"
.
Font selection is SimSun.
python main.py example stop SimSun
- The input file is
"in/example.txt"
- The stop file is
"stop.txt"
- The resulting word cloud image is
"out/example.png"
. - The chosen font is
fonts/SimSun.ttf
.
python main.py file stop font
- Parameter 1 (file): The name of the input file (".txt" is optional). If not provided, the default is "test.txt".
- Parameter 2 (stop): The stopwords file (".txt" is optional). If not provided, the default is "stop.txt"
- Parameter 3 (font): The font (".ttf" is optional). If not provided, the default is "SimHei.ttf".
Thanks to @StellarCN for providing the font SimHei
. Wishing StellarCN continued success.
Thanks to Sociology and Political Science student @Esme from Shanghai University for the requirements, which inspired me to write this small tool.