赞
踩
应粉丝要求:
粉丝的彩虹屁,不好意思放出来。。。打码了
import jieba
import matplotlib.pyplot as plt
from wordcloud import WordCloud
text = open("a.txt",encoding='gbk').read() # 标明文本路径,打开
# 生成对象
stopwords = ['论述题','分共','每小题','15分','简答题','案例分析题','每小题10分','名词解释','分','共','每小题','共']
wc = WordCloud(font_path="msyh.ttc", width=500, height=400, mode="RGBA",stopwords=stopwords,
background_color=None).generate(text)
# 显示词云图
plt.imshow(wc, interpolation="bilinear")
plt.axis("off")
plt.show()
# 保存文件
wc.to_file("ciyun1.png")
代码:
import imageio
import jieba
from wordcloud import WordCloud
def jieba_cut():
fr_xyj=open('E:/data/luyin/redian.txt','r',encoding='utf-8')
s=fr_xyj.read()
words=jieba.cut(s,cut_all=False)
word_dict={}
#print(type(word_dict)) dict
word_list=''
#print(type(word_list)) string
for word in words:
if (len(word) > 1 ):
word_list = word_list + ' ' + word
if (word_dict.get(word)):
word_dict[word] = word_dict[word] + 1
else:
word_dict[word] = 1
##print(word_list)
print(word_dict)
sort_words=sorted(word_dict.items(),key=lambda x:x[1],reverse=True)
print(type(sort_words))
print(sort_words[0:101])#���ǰ0-100�Ĵ�
word_100 = {}
count=0
for i in sort_words[0:201]:
print(i)
word_100[i[0]] = i[1]
count=count+1
# for key, value in sort_words():
# print(key, value)
print(count)
color_mask =imageio.imread("1.jpg")
wc = WordCloud(
background_color="black",
#max_words=500,
font_path="msyh.ttc",
# min_font_size=15,
# max_font_size=120,
width=400,
height=860,
mask=color_mask)
i=str('why')
wc.generate(word_list)
wc.to_file(str(i)+".png")
jieba_cut()
运行结果:
('教育', 32)
('简述', 22)
('论述', 21)
('理论', 12)
('思想', 10)
('333', 9)
('名词解释', 9)
('简答题', 9)
('教学', 9)
('论述题', 9)
('发展', 9)
('德育', 7)
('特点', 7)
('及其', 7)
('课程', 6)
('影响', 6)
('原则', 5)
('内容', 5)
('启示', 5)
('教师', 5)
('基本', 4)
('哪些', 4)
('如何', 4)
('过程', 4)
('关系', 4)
('学习', 4)
('30', 4)
('40', 4)
('80', 4)
('工作', 3)
('强化', 3)
('陶行知', 3)
('生活', 3)
('杜威', 3)
('我们', 3)
('评价', 3)
('理解', 3)
('因素', 3)
('要求', 3)
('联系实际', 3)
('时期', 3)
('美国', 3)
('运动', 3)
('活动', 2)
('颜之推', 2)
('家庭教育', 2)
('惩罚', 2)
('之间', 2)
('分析', 2)
('认知', 2)
('功能', 2)
('问题', 2)
('解决', 2)
('意义', 2)
('朱子', 2)
('读书', 2)
('劳动', 2)
('苏格拉底', 2)
('方法', 2)
('试论', 2)
('地位', 2)
('稷下', 2)
('学宫', 2)
('培养', 2)
('最近', 2)
('途径', 2)
('学习动机', 2)
('要素', 2)
('制度', 2)
('主义', 2)
('目的', 2)
('心理健康', 2)
('2014', 1)
('教学方法', 1)
('发论', 1)
('正式', 1)
('群体', 1)
('环节', 1)
('什么', 1)
('主要', 1)
('比较', 1)
('奖励', 1)
('异同', 1)
('规定性', 1)
('体现', 1)
('哪些方面', 1)
('评述', 1)
('现实', 1)
('评析', 1)
('实用主义', 1)
('试述', 1)
('皮亚杰', 1)
('说明', 1)
('2015', 1)
('班级', 1)
('授课', 1)
('课程标准', 1)
('纲领', 1)
('条目', 1)
('门学', 1)
('性质', 1)
('政治', 1)
('卢梭', 1)
('自然主义', 1)
('规律性', 1)
('重要', 1)
('教材', 1)
('相关', 1)
('现实意义', 1)
('韦纳', 1)
('归因', 1)
('2016', 1)
('角色', 1)
('校长', 1)
('负责制', 1)
('学记', 1)
('应当', 1)
('处理', 1)
('哪几种', 1)
('实质', 1)
('相对', 1)
('独立性', 1)
('美纽斯', 1)
('教育史', 1)
('结合', 1)
('例子', 1)
('谈谈', 1)
('区别', 1)
('2017', 1)
('狭义', 1)
('学习策略', 1)
('洛克', 1)
('素质教育', 1)
('本质', 1)
('贯彻', 1)
('知识', 1)
('中国', 1)
('古代', 1)
('书院', 1)
('情意', 1)
('班主任', 1)
('素质', 1)
('晏阳初', 1)
('乡村', 1)
('苏霍姆', 1)
('林斯基', 1)
('2018', 1)
('讲授法', 1)
('相对性', 1)
('六艺', 1)
('鹤群', 1)
('教育论', 1)
('素养', 1)
('把握', 1)
('主导', 1)
('和学', 1)
('主动性', 1)
('建构主义', 1)
('2019', 1)
('本位', 1)
('----', 1)
('第四章', 1)
('外国', 1)
('学在', 1)
('官府', 1)
('克思', 1)
('关于', 1)
('董仲舒', 1)
('罢黜百家', 1)
('独尊', 1)
('儒术', 1)
('编制', 1)
('科举制', 1)
('复兴', 1)
('主义教育', 1)
('加德纳', 1)
('多元', 1)
('述评', 1)
('我国', 1)
(
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。