##Features Based on word_cloud and word cloud generate, I created this easy word cloud.
- Super easy to user. Compared to word cloud, easy_word_cloud provide a simplier interface and you do not need to have cython.
- More effcient. Easy_word_cloud is more effcient with bigger canvas or a plenty of words.
- Using weight instead of count. You can set the weiht to whatever you want( e.g. the count of word, log(count of word) ) only if you ensure it great than 0.
- font size is strict liner with weight. In order to provide a more reasonable figure, the weight is liner with the font size. In word_cloud, the size of two words are not compareable because it doest not maintain the linearity.
- Smart draw. I design a algorithm to smart choice font size with regard to the size of word, weight distribution of word and size of the canvas.
- Unicode and python2/3 support.
Fast install:
sudo pip install git+git://github.com/knightwu/easy_word_cloud.git
Otherwise, get this package:
wget https://github.com/knightwu/easy_word_cloud/archive/master.zip
unzip master.zip
rm master.zip
cd easy_word_cloud-master
Install the requirements:
sudo pip install -r requirements.txt
If you are a windows user, you can download the package needed from Unofficial Windows Binaries for Python Extension Packages
Install the package:
sudo python setup.py install
##How to draw a word cloud? prepare the a list of word tuples. and then call the function
English
text = open(path.join(d, 'examples/constitution.txt')).read()
words = easywordcloud.process_text(text)
# to makes the weight more even
words = [(word, math.sqrt(weight)) for word, weight in words]
easywordcloud.draw_word_cloud(words, width, height, 'examples/constitution.png')
Englih with font Andale Mono
text = open(path.join(d, 'examples/alice.txt')).read()
words = easywordcloud.process_text(text)
easywordcloud.draw_word_cloud(words, width, height,
'examples/alice.png',
'/Library/Fonts/Andale Mono.ttf')
Chinese
#python2
words = [(u'标签', 3), (u'云', 2)]
#pyton3
#words = [('标签', 3), ('云', 2)]
easywordcloud.draw_word_cloud(words, width, height, 'examples/chinese.png', None)
Japanness
#python2
words = [(u'ワード', 0.7), (u'クラウド', 0.6)]
#python3
#words = [('ワード', 0.7), ('クラウド', 0.6)]
easywordcloud.draw_word_cloud(words, width, height, 'examples/japanese.png', None)
NOTE: MAKE SURE THE FONT COVERS THE CHARACTERS YOU WANT TO DISPLAY If you are not on mac, you need to adjust FONT_PATH to point to some existing font.
Check out examples/simple.py for a short intro.