【发布时间】:2020-06-18 02:32:09
【问题描述】:
我创建了词云。
# Python程序生成WordCloud
# importing all necessery modules
from wordcloud import WordCloud, STOPWORDS
import matplotlib.pyplot as plt
import pandas as pd
from collections import Counter
from konlpy.tag import Okt
# Reads 'Youtube04-Eminem.csv' file
df = pd.read_excel(r"crawling.xlsx", encoding="UTF8")
comment_words = ''
# iterate through the csv file
for val in df.CONTENT:
# typecaste each val to string
val = str(val)
okt=Okt()
noun=okt.nouns(val)
for i,v in enumerate(noun):
if len(v)<2:
noun.pop(i)
comment_words += " ".join(noun) + " "
count=Counter(noun)
noun_list=count.most_common(100)
stopwords = set(STOPWORDS)
stopwords.add("모든언어")
stopwords.add("모든결과")
STOPWORDS.add("모든날짜")
STOPWORDS.add('지난지난')
wordcloud = WordCloud(width=800, height=800,
font_path='NanumBarunGothic.otf',
background_color='white',
stopwords=stopwords,
min_font_size=10).generate(comment_words)
# plot the WordCloud image
plt.figure(figsize=(8, 8), facecolor=None)
plt.imshow(wordcloud)
plt.axis("off")
plt.tight_layout(pad=0)
plt.savefig('word_cloud.png')
plt.show()
我将词云停用词添加到集合中,但它没有反映在结果中。 另外,我制作了一个停用词列表并将它们放入,但它没有用。 我该怎么办
【问题讨论】:
标签: python word-cloud