반응형
wordcloud시 불용어 지정
>pip install wordcloud
from wordcloud import WordCloud
texts = ['이것 은 예문 입니다', '여러분 의 문장을 넣 으세요']
keywords = {'이것':5, '예문':3, '단어':5, '빈도수':3}
wordcloud = WordCloud()
wordcloud = wordcloud.generate_from_text(texts)
wordcloud = wordcloud.generate_from_frequencies(keywords)
###########################################
from wordcloud import WordCloud
from wordcloud import STOPWORDS
stopwords = {'은', '입니다'}
wordcloud = WordCloud(stopwords=stopwords)
wordcloud = wordcloud.generate_from_text(texts)
keywords.pop('영화')
keywords.pop('관람객')
keywords.pop('너무')
keywords.pop('정말')
from wordcloud import WordCloud
wordcloud = WordCloud(
width = 800,
height = 800
)
wordcloud = wordcloud.generate_from_frequencies(keywords)
font_path = '/usr/share/fonts/truetype/nanum/NanumBarunGothic.ttf'
from wordcloud import WordCloud
wordcloud = WordCloud(
font_path = font_path,
width = 800,
height = 800
)
wordcloud = wordcloud.generate_from_frequencies(keywords)
from wordcloud import WordCloud
wordcloud = WordCloud(
font_path = font_path,
width = 800,
height = 800
)
wordcloud = wordcloud.generate_from_frequencies(keywords)
%matplotlib inline
import matplotlib.pyplot as plt
fig = plt.figure(figsize=(10, 10))
plt.imshow(array, interpolation="bilinear")
plt.show()
fig.savefig('wordcloud_without_axisoff.png')
from wordcloud import WordCloud, STOPWORDS
import matplotlib.pyplot as plt
stopwords = set(STOPWORDS)
stopwords.add('워드클라우드')
wordcloud = WordCloud(font_path='font/NanumGothic.ttf',stopwords=stopwords,background_color='white').generate(text)
반응형
'프로그래밍 > Python' 카테고리의 다른 글
Sublime Text 3에서 Python 프로그래밍을 하기 위해 필요한 설정을 다루고 있습니다. (0) | 2020.12.16 |
---|---|
[python] style cloud 설정 (0) | 2020.12.15 |
[python] sorted, 문자열 길이로 정렬, 한글 정렬 (0) | 2020.12.15 |
[python] 큰 파일 분할해서 만들기 (0) | 2020.12.14 |
[python] konlpy - Okt, komoran, Pykomoran (0) | 2020.12.14 |