AnKiWoong 2019. 4. 13. 16:05
반응형

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>


반응형