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
39d74c35
Commit
39d74c35
authored
Dec 05, 2015
by
Raphael Boidol
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
merge plurals before choosing case of word to keep so different cases are merged, too
parent
6100640c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
10 deletions
+12
-10
wordcloud/wordcloud.py
wordcloud/wordcloud.py
+12
-10
No files found.
wordcloud/wordcloud.py
View file @
39d74c35
...
...
@@ -368,22 +368,24 @@ class WordCloud(object):
# Look in any case dict.
d2
[
word
]
=
d2
.
get
(
word
,
0
)
+
1
# merge plurals into the singular count (simple cases only)
for
key
in
list
(
d
.
keys
()):
if
key
.
endswith
(
's'
):
key_singular
=
key
[:
-
1
]
if
key_singular
in
d
:
dict_plural
=
d
[
key
]
dict_singular
=
d
[
key_singular
]
for
word
,
count
in
dict_plural
.
items
():
singular
=
word
[:
-
1
]
dict_singular
[
singular
]
=
dict_singular
.
get
(
singular
,
0
)
+
count
del
d
[
key
]
d3
=
{}
for
d2
in
d
.
values
():
# Get the most popular case.
first
=
max
(
d2
.
items
(),
key
=
item1
)[
0
]
d3
[
first
]
=
sum
(
d2
.
values
())
# merge plurals into the singular count (simple cases only)
for
key
in
list
(
d3
.
keys
()):
if
key
.
endswith
(
's'
):
key_singular
=
key
[:
-
1
]
if
key_singular
in
d3
:
val_plural
=
d3
[
key
]
val_singular
=
d3
[
key_singular
]
d3
[
key_singular
]
=
val_singular
+
val_plural
del
d3
[
key
]
return
d3
.
items
()
def
generate_from_text
(
self
,
text
):
...
...
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