-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3d6b3b3
commit 0269230
Showing
11 changed files
with
150 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
build | ||
wordcloud/query_integral_image.c | ||
wordcloud/query_integral_image.so | ||
/wordcloud/query_integral_image.c | ||
/wordcloud/query_integral_image.so | ||
*.pyc | ||
*~ | ||
*.png | ||
!/examples/constitution.png | ||
!/examples/alice.png |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,18 @@ | ||
|
||
Copyright (c) 2012 Andreas Christian Mueller | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy of | ||
this software and associated documentation files (the "Software"), to deal in | ||
the Software without restriction, including without limitation the rights to | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies | ||
of the Software, and to permit persons to whom the Software is furnished to do | ||
so, subject to the following conditions: | ||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of | ||
the Software, and to permit persons to whom the Software is furnished to do so, | ||
subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. | ||
|
||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS | ||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR | ||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER | ||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,58 @@ | ||
word_cloud | ||
========== | ||
|
||
A fork of [Andreas Mueller](https://github.com/amueller)'s | ||
[word_cloud](https://github.com/amueller/word_cloud) to make it a little more | ||
extendable and installable as a package. | ||
A little word cloud generator in Python. Read more about it on the [blog | ||
post][blog-post]. | ||
|
||
Install it by running: | ||
|
||
pip install Cython | ||
pip install numpy | ||
pip install PIL | ||
## Installation | ||
|
||
Get this package: | ||
|
||
wget https://github.com/paul-nechifor/word_cloud/archive/master.zip | ||
unzip master.zip | ||
rm master.zip | ||
cd word_cloud-master | ||
sudo python setup.py install | ||
cd .. | ||
sudo rm -r word_cloud-master master.zip | ||
|
||
Run the files in `examples/` to for a short intro. | ||
Install it: | ||
|
||
sudo pip install -r requirements.txt | ||
sudo python setup | ||
|
||
## Examples | ||
|
||
Note that if you are not on Ubuntu, you need to adjust FONT_PATH to point to | ||
some existing font. | ||
|
||
Check out [examples/simple.py][simple] for a short intro. A sample output is: | ||
|
||
![Constitution](examples/constitution.png) | ||
|
||
Or run [examples/more.py][more] to see more options. | ||
|
||
## Used in | ||
|
||
### Reddit Cloud | ||
|
||
[Reddit Cloud][reddit-cloud] is a Reddit bot which generates word clouds for | ||
comments in submissions and user histories. You can see it being operated on | ||
[/u/WordCloudBot2][wc2] ([top posting][wc2top]). | ||
|
||
![A Reddit Cloud sample](http://i.imgur.com/tcbZnKW.png) | ||
|
||
### <other> | ||
|
||
*Send a pull request to add yours here.* | ||
|
||
## Issues | ||
|
||
Using Pillow instead of PIL might might get you the [`TypeError: 'int' object is | ||
not iterable` problem][intprob] also showcased on the blog. | ||
|
||
[blog-post]: http://peekaboo-vision.blogspot.de/2012/11/a-wordcloud-in-python.html | ||
[simple]: examples/simple.py | ||
[simple]: examples/more.py | ||
[reddit-cloud]: https://github.com/paul-nechifor/reddit-cloud | ||
[wc2]: http://www.reddit.com/user/WordCloudBot2 | ||
[wc2top]: http://www.reddit.com/user/WordCloudBot2/?sort=top | ||
[intprob]: http://peekaboo-vision.blogspot.de/2012/11/a-wordcloud-in-python.html#bc_0_28B | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,17 @@ | ||
#!/usr/bin/env python2 | ||
|
||
from os import path | ||
import sys | ||
import os | ||
import wordcloud | ||
|
||
text = open('alice.txt').read() | ||
words, counts = wordcloud.process_text(text, max_features=2000) | ||
elements = wordcloud.fit_words(words, counts, width=500, height=500) | ||
wordcloud.draw(elements, 'alice.png', width=500, height=500, scale=2) | ||
d = path.dirname(__file__) | ||
|
||
# Read the whole text. | ||
text = open(path.join(d, 'alice.txt')).read() | ||
# Separate into a list of (word, frequency). | ||
words = wordcloud.process_text(text, max_features=2000) | ||
# Compute the position of the words. | ||
elements = wordcloud.fit_words(words, width=500, height=500) | ||
# Draw the positioned words to a PNG file. | ||
wordcloud.draw(elements, path.join(d, 'alice.png'), width=500, height=500, | ||
scale=2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
#!/usr/bin/env python2 | ||
|
||
from os import path | ||
import sys | ||
import os | ||
import wordcloud | ||
|
||
text = open('constitution.txt').read() | ||
words, counts = wordcloud.process_text(text) | ||
elements = wordcloud.fit_words(words, counts) | ||
wordcloud.draw(elements, 'constitution.png') | ||
d = path.dirname(__file__) | ||
|
||
# Read the whole text. | ||
text = open(path.join(d, 'constitution.txt')).read() | ||
# Separate into a list of (word, frequency). | ||
words = wordcloud.process_text(text) | ||
# Compute the position of the words. | ||
elements = wordcloud.fit_words(words) | ||
# Draw the positioned words to a PNG file. | ||
wordcloud.draw(elements, path.join(d, 'constitution.png')) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Cython>=0.19.1 | ||
PIL>=1.1.7 | ||
numpy>=1.7.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
import os | ||
from distutils.core import setup | ||
from Cython.Build import cythonize | ||
|
||
setup( | ||
name='wordcloud', | ||
ext_modules=cythonize('wordcloud/query_integral_image.pyx'), | ||
version='1.0.0', | ||
url='https://github.com/paul-nechifor/word_cloud', | ||
license='MIT', | ||
ext_modules=cythonize('wordcloud/query_integral_image.pyx'), | ||
packages=['wordcloud'], | ||
package_data={'wordcloud': ['stopwords']} | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters