Generate a word cloud from text/file/directory, file and directory only effective with file, you can specify certain width and height or mask file to generate a imaginative shape word cloud
Run on python3.x,and install the following packages if you find the package does not exist:
bash
# create a word cloud with certain width and height
python {baseDir}/scripts/generate_wordcloud.py --target_text "..." --width 500 --height 400 --max_words 30 --font_path "C:\Windows\Fonts\msyh.ttc" --output_dir "..."
# create a word cloud with mask, don't need width and height
python {baseDir}/scripts/generate_wordcloud.py --target_text "..." --mask "..." --font_path "C:\Windows\Fonts\msyh.ttc" --output_dir "..."
namedescriptiontypeexampletarget_texttext to generate word cloudstring"你好,世界"target_filetext in the file to generate word cloudstring"D:\WorkSpace\pythonSpace\MEMORY.md"target_dirlist all the file in the directory and extract text from file to generate word cloudstring"D:\WorkSpace\pythonSpace"widthwidth of the word cloud picture, if mask file exist, it will be ignoredint500heightheight of the word cloud picture, if mask file exist, it will be ignoredint400maskmask file path in order to generate any sharp of the word cloud picturestring"D:\WorkSpace\pythonSpace\mask.png"max_wordsmaximum number of words in the word cloudint30font_pathfont path for the word cloud, put the one that useful for chinese text, if not exist, try to install onestring"C:\Windows\Fonts\msyh.ttc"output_dirword cloud picture output directory path, if user not specify, put it into the folder whilc named "images" under the user directorystring"D:\WorkSpace\pythonSpace"
text
- hello
- world