Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
word_cloud_est
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
keeleliin
word_cloud_est
Commits
bef83e5a
Commit
bef83e5a
authored
Dec 05, 2015
by
Raphael Boidol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
use itemgetter for sorting, and remove unneccessary max after sort
parent
543333be
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
4 deletions
+3
-4
wordcloud/wordcloud.py
wordcloud/wordcloud.py
+3
-4
No files found.
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
Markdown
is supported
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