目录
一、"*工作报告词云"问题分析
1.1 问题分析
直观理解政策文件
- 需求:对于*工作报告等政策文件,如何直观理解?
- 体会直观的价值:生成词云 & 优化词云
*工作报告等文件 --> 有效展示的词云
《决胜全面建成小康社会 夺取新时代中国特色*伟大胜利》—— 在中国共...第十九次全国代表大会上的报告(2017年10月18日)习大大:http://www.chenyoude.com/预科班/新时代中国特色*.html
《** 国务院关于实施乡村振兴战略的意见》 —— 2018一号文件(2018年01月02日)** 国务院:http://www.chenyoude.com/预科班/关于实施乡村振兴战略的意见.html
二、"*工作报告词云"实例讲解(上)
2.1 *工作报告词云
基本思路
- 步骤1:读取文件、分词整理
- 步骤2:设置并输出词云
- 步骤3:观察结果,优化迭代
2.2 新时代中国特色*
# GovRptWordCloudv1.py
import jieba
import wordcloud
f = open("新时代中国特色*.txt", "r", encoding="utf-8")
t = f.read()
f.close()
ls = jieba.lcut(t)
txt = " ".join(ls)
w = wordcloud.WordCloud(font_path = "/Library/Fonts/Heiti.ttc",width = 1000, height = 700, background_color = "white")
w.generate(txt)
w.to_file("grwordcloud.png")
2.3 2018年一号文件
# GovRptWordCloudv1.py
import jieba
import wordcloud
f = open("关于实施乡村振兴战略的意见.txt", "r", encoding="utf-8")
t = f.read()
f.close()
ls = jieba.lcut(t)
txt = " ".join(ls)
w = wordcloud.WordCloud(font_path = "/Library/Fonts/Heiti.ttc",width = 1000, height = 700, background_color = "white")
w.generate(txt)
w.to_file("grwordcloud.png")
2.4 新时代中国特色*
# GovRptWordCloudv1.py
import jieba
import wordcloud
f = open("新时代中国特色*.txt", "r", encoding="utf-8")
t = f.read()
f.close()
ls = jieba.lcut(t)
txt = " ".join(ls)
w = wordcloud.WordCloud(font_path = "/Library/Fonts/Heiti.ttc",width = 1000, height = 700, background_color = "white")
w.generate(txt)
w.to_file("grwordcloud.png")
2.5 2018年一号文件
# GovRptWordCloudv1.py
import jieba
import wordcloud
f = open("关于实施乡村振兴战略的意见.txt", "r", encoding="utf-8")
t = f.read()
f.close()
ls = jieba.lcut(t)
txt = " ".join(ls)
w = wordcloud.WordCloud(font_path = "/Library/Fonts/Heiti.ttc",width = 1000, height = 700, background_color = "white")
w.generate(txt)
w.to_file("grwordcloud.png")
三、"*工作报告词云"实例讲解(下)
3.1 *工作报告词云
更有形的词云
3.2 五角星
# GovRptWordCloudv2.py
import jieba
import wordcloud
from scipy.misc import
imread mask = imread("fivestart.png")
f = open("新时代中国特色*.txt", "r", encoding="utf-8")
t = f.read()
f.close()
ls = jieba.lcut(t)
txt = " ".join(ls)
w = wordcloud.WordCloud(font_path = "/Library/Fonts/Heiti.ttc",width = 1000, height = 700, background_color = "white", mask=mask)
w.generate(txt)
w.to_file("grwordcloud.png")
3.3 中国地图
# GovRptWordCloudv2.py
import jieba
import wordcloud
from scipy.misc import
imread mask = imread("chinamap.jpg?x-oss-process=style/watermark")
f = open("新时代中国特色*.txt", "r", encoding="utf-8")
t = f.read()
f.close()
ls = jieba.lcut(t)
txt = " ".join(ls)
w = wordcloud.WordCloud(font_path = "/Library/Fonts/Heiti.ttc",width = 1000, height = 700, background_color = "white", mask=mask)
w.generate(txt)
w.to_file("grwordcloud.png")
四、"*工作报告词云"举一反三
4.1 扩展能力
- 了解wordcloud更多参数,扩展词云能力
- 特色词云:设计一款属于自己的特色词云风格
- 更多文件:用更多文件练习词云生成