반응형

wordcloud 패키지 설치 명령어

conda install -c conda-forge wordcloud




만약 설치후에도  오류가 발생한다면

wordcloud 패키지를 지우고 선행 패키지인 pillow 패키지를 먼저 설치한 후 wordcloud 패키지를 다시 설치한다.

 

> stylecloud 도 설치 하자. 

pip install stylecloud

 

 

 

반응형
반응형

style cloud 설정

 

> pip install stylecloud

 

 

- file_path: 입력할 데이터를 텍스트 문서로 지정합니다.

- text: 입력할 데이터를 딕셔너리 자료형으로 지정합니다.

- font_path: 워드클라우드를 그릴 path를 지정합니다.

- size: 사이즈를 지정, (1024, 512)과 같은 형식으로 입력합니다.

- background_color: 배경색을 지정한다. 색이름을 입력하면 된다. ( 예) white )

- icon_name: 어떤 모양으로 그릴 지 입력합니다. fab fa-twitter(트워터 모양), fas fa-dog(강아지), fas fa-flag(깃발), fas fa-fish(물고기) 등이 있다. 띄어쓰기 앞은 폰트를 의미하고, 뒤에는 모양을 의미한다. 그릴 수 있는 모양은 가지수가 좀 많은데, stylecolud패키지가 설치된 폴더에서 static폴더 밑에 fontawesome.min.css파일을 확인하면 알 수 있다.

- font_path: 폰트를 지정한다.

- output_name: 결과를 파일로 저장한다.

 

Generate Modern Stylish Wordcloud : towardsdatascience.com/generate-modern-stylish-wordcloud-with-stylecloud-9cbb059696d2

 

Generate Modern Stylish Wordcloud with stylecloud

But deep down, all of us have always wished for modern-stylish-beautiful wordclouds. That wish has become true with this new python…

towardsdatascience.com

파이썬 wordcloud를 사용한 한글 명사 시각화 :  liveyourit.tistory.com/58

 

파이썬 wordcloud를 사용한 한글 명사 시각화

파이썬 wordcloud는 중요한 단어나 키워드를 시각화해서 보여주는 시각화 도구이다. wordcloud 자체적으로 빈도수를 계산하는 기능이 있다고 하지만 아무래도 한글의 특성이 있다보니, 나는 한글 명

liveyourit.tistory.com

 

#워드 클라우드, 파이썬에서 이쁘게 그리는 방법은 tariat.tistory.com/854?category=678887

 

워드 클라우드, 파이썬에서 이쁘게 그리는 방법은?!

빅데이터가 많은 사람들에게 관심을 받기 시작할 때 많이 볼 수 있었던 것 중에 하나로 워드 클라우드가 있다. 워드 클라우드는 단어별 빈도수를 기준으로 한 단순한 시각화에 불과하지만, 그림

tariat.tistory.com

 

반응형
반응형

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)
 
 

 

반응형
반응형

 Wordcloud 만들기 


from collections import Counter
from konlpy.tag import Twitter
import pytagcloud
 
f = open('blog_data.txt')
data = f.read()
 
nlp = Twitter()
nouns = nlp.nouns(data)
 
count = Counter(nouns)
tags2 = count.most_common(40)
taglist = pytagcloud.make_tags(tags2, maxsize=80)
pytagcloud.create_tag_image(taglist, 'wordcloud.jpg', size=(900, 600), fontname='korean', rectangular=False)
 
f.close()



반응형
반응형

wordcloud2.js




Create a tag cloud/Wordle presentation on 2D canvas or HTML.

This library is a spin-off project from HTML5 Word Cloud.

Visit the demo page

Simple usage

Load wordcloud.js script to the web page, and run:

WordCloud(document.getElementById('my_canvas'), { list: list } );

where list is an array that look like this: [['foo', 12], ['bar', 6]].

Options available, see API documentation for detail.

Algorithm

Before putting each word on the canvas, it is drawn on a separate canvas to read back the pixels to record is drawn spaces. With the information, wordcloud.js will then try to find a place to fit the word that is closest to the start point.

Testing

Tests are available with QUnit and grunt. To setup environment for testing, run npm install and manually install SlimerJS of your platform.

Use grunt test to ensure all options can be set without JavaScript error.

Use grunt compare --base-commit=gh-pages to compare your proposed fix with gh-pages branch.

Acknowledgement

The developer would like to thank Chad Jensen for sponsoring the work on image masking on the demo page.


반응형

+ Recent posts