Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
keeleliin
word_cloud_est
Commits
031449e2
Commit
031449e2
authored
Sep 22, 2014
by
Andreas Mueller
Browse files
adjust simple example to new interface
parent
c1014d10
Changes
4
Hide whitespace changes
Inline
Side-by-side
examples/alice.png
View replaced file @
c1014d10
View file @
031449e2
446 KB
|
W:
|
H:
138 KB
|
W:
|
H:
2-up
Swipe
Onion skin
examples/constitution.png
View replaced file @
c1014d10
View file @
031449e2
56.1 KB
|
W:
|
H:
54.5 KB
|
W:
|
H:
2-up
Swipe
Onion skin
examples/masked.py
View file @
031449e2
...
...
@@ -20,7 +20,13 @@ plt.imshow(alice_mask)
wc
=
WordCloud
(
background_color
=
"white"
,
max_words
=
2000
,
mask
=
alice_mask
,
stopwords
=
STOPWORDS
.
add
(
"said"
))
# generate word cloud
wc
.
generate
(
text
)
# store to file
wc
.
to_file
(
path
.
join
(
d
,
"alice.png"
))
# show
plt
.
figure
()
plt
.
imshow
(
wc
)
plt
.
show
()
examples/simple.py
View file @
031449e2
#!/usr/bin/env python2
from
os
import
path
import
sys
import
wordcloud
from
wordcloud
import
WordCloud
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
)
wordcloud
=
WordCloud
().
generate
(
text
)
# Draw the positioned words to a PNG file.
wordcloud
.
draw
(
elements
,
path
.
join
(
d
,
'constitution.png'
))
wordcloud
.
to_file
(
path
.
join
(
d
,
'constitution.png'
))
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment