Skip to content
GitLab
Menu
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
907b62a0
Commit
907b62a0
authored
Feb 02, 2016
by
Marianne Corvellec
Browse files
Let process_text() return a dict.
parent
740b3e0c
Changes
2
Hide whitespace changes
Inline
Side-by-side
test/test_wordcloud.py
View file @
907b62a0
...
...
@@ -169,6 +169,15 @@ def test_single_color_func_grey():
assert_equal
(
red_function
(
random_state
=
random
),
'rgb(56, 56, 56)'
)
def
test_process_text
():
# test that process function returns a dict
wc
=
WordCloud
(
max_words
=
50
)
result
=
wc
.
process_text
(
THIS
)
# check for proper return type
assert_true
(
isinstance
(
result
,
dict
))
def
check_parameters
():
# check that parameters are actually used
pass
wordcloud/wordcloud.py
View file @
907b62a0
...
...
@@ -427,7 +427,7 @@ class WordCloud(object):
first
=
max
(
d2
.
items
(),
key
=
item1
)[
0
]
d3
[
first
]
=
sum
(
d2
.
values
())
return
d3
.
items
()
return
d3
def
generate_from_text
(
self
,
text
):
"""Generate wordcloud from text.
...
...
@@ -439,7 +439,7 @@ class WordCloud(object):
self
"""
words
=
self
.
process_text
(
text
)
self
.
generate_from_frequencies
(
words
)
self
.
generate_from_frequencies
(
words
.
items
()
)
return
self
def
generate
(
self
,
text
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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