
!pip3 install WordCloud
!pip3 install konlpy
from wordcloud import WordCloud
from collections import Counter
from konlpy.tag import Okt
from konlpy.tag import Komoran
from PIL import Image
import matplotlib.pyplot as plt
import numpy as np
with open('C:\\Users\\dd\\Desktop\\Virtual_Hadoop\\04.WordCount\\대한민국헌법.txt', 'r', encoding='utf-8') as f:
text = f.read()
okt = Okt()
nouns = okt.nouns(text)
words = [n for n in nouns if len(n) > 1]
wcnt = Counter(words)
wc = WordCloud(font_path='malgun', width=400, height=400, scale=2.0, max_font_size=250)
gen = wc.generate_from_frequencies(wcnt)
plt.figure()
plt.imshow(gen)
