Python Word Cloud「文字雲」文字分析
更新:
更新至 python3.9 版本使用 counter 需加入
from collections import Counter
pandas 排序次數問題:
transform-a-counter-object-into-a-pandas-dataframe
摘要
練習如何斷詞: https://github.com/wastu01/Jieba-ChinsesWord
文章內容給 Jieba 斷詞,並分析文字產生文字雲, 可推測其文章重要字詞以及核心內容
線上文字雲
http://www.tagxedo.com/gallery.html
文字雲輸出內容:
執行畫面
載入相關套件(requirement)
import jieba
import matplotlib.pyplot as plt
import numpy as np
from PIL import Image
from wordcloud import WordCloud, ImageColorGenerator
from scipy.ndimage import gaussian_gradient_magnitude
Mac OS X 系统文字路徑 (字體檔案複製貼到 terminal 即可查看)
相關檔案在資料夾當中
-
txt 資料夾:完整文字檔
-
img 資料夾:文字雲圖片
圖片遮罩來源取用自 Unsplash
Photo by Remi Yuan on Unsplash
Photo by Vernon Raineil Cenzon on Unsplash
延伸應用: