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
bef83e5a
Commit
bef83e5a
authored
Dec 05, 2015
by
Raphael Boidol
Browse files
use itemgetter for sorting, and remove unneccessary max after sort
parent
543333be
Changes
1
Hide whitespace changes
Inline
Side-by-side
wordcloud/wordcloud.py
View file @
bef83e5a
...
...
@@ -227,13 +227,12 @@ class WordCloud(object):
"""
# make sure frequencies are sorted and normalized
frequencies
=
sorted
(
frequencies
,
key
=
lambda
x
:
x
[
1
]
,
reverse
=
True
)
frequencies
=
sorted
(
frequencies
,
key
=
item1
,
reverse
=
True
)
frequencies
=
frequencies
[:
self
.
max_words
]
# largest entry will be 1
max_frequency
=
float
(
np
.
max
([
freq
for
word
,
freq
in
frequencies
]
)
)
max_frequency
=
float
(
frequencies
[
0
][
1
])
for
i
,
(
word
,
freq
)
in
enumerate
(
frequencies
):
frequencies
[
i
]
=
word
,
freq
/
max_frequency
frequencies
=
[
(
word
,
freq
/
max_frequency
)
for
word
,
freq
in
frequencies
]
self
.
words_
=
frequencies
...
...
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