python根据文本生成词云图 效果 代码 from wordcloud import WordCloud import codecs import jieba #import jieba.analyse as analyse from scipy.misc import imread import os from os import path import matplotlib.pyplot as plt from PIL import Image, ImageDraw, ImageFont
环境搭建: pip install itchat numpy wordcloud matplotlib jieba 先把上面的几个包安装完成,直接上代码 import itchat from itchat.content import TEXT import re import os import numpy as np from PIL import Image from wordcloud.wordcloud import WordCloud if itchat.load_login_sta
1. 先下载并安装nltk包,准备一张简单的图片存入代码所在文件目录,搜集英文停用词表 import nltk nltk.download() 2. 绘制词云图 import re import numpy as np import pandas as pd #import matplotlib import matplotlib.pyplot as plt from nltk.tokenize import word_tokenize, sent_tokenize from nltk.corp