반응형
Python Code>
from wordcloud import WordCloud
from matplotlib import pyplot
from wordcloud import STOPWORDS
from PIL import Image
import numpy
text = ''
with open("데이터위치", encoding="utf-8") as f:
text = f.read()
ignore = set(STOPWORDS)
ignore.add("금칙어")
img = Image.open("배경화면위치");
img_array = numpy.array(img)
wc = WordCloud(background_color="white", width=600, height=1200, max_font_size=150, scale=2.0,
max_words=100, stopwords=ignore, mask=img_array, contour_color='steelblue')
gen = wc.generate(text)
pyplot.figure()
pyplot.imshow(gen, interpolation='bilinear')
wc.to_file("결과물파일명")
pyplot.close()
O>
반응형
'Python_Intermediate > WordCloud' 카테고리의 다른 글
WordCloud Option Background image (0) | 2019.04.20 |
---|---|
WordCloud Option Forbidden word (0) | 2019.04.20 |
WordCloud Basic (0) | 2019.04.20 |
WordCloud Module Import (0) | 2019.04.20 |
Koera Constitution WordCloud (0) | 2019.04.13 |