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
57e733d2
Commit
57e733d2
authored
Mar 01, 2016
by
terrycojones
Browse files
Use a set for the (lowercase) stopwords, instead of looking up every word via linear search.
parent
0869b1f2
Changes
1
Hide whitespace changes
Inline
Side-by-side
wordcloud/wordcloud.py
View file @
57e733d2
...
...
@@ -200,8 +200,6 @@ class WordCloud(object):
color_func
=
random_color_func
,
max_words
=
200
,
min_font_size
=
4
,
stopwords
=
None
,
random_state
=
None
,
background_color
=
'black'
,
max_font_size
=
None
,
font_step
=
1
,
mode
=
"RGB"
,
relative_scaling
=
0
):
if
stopwords
is
None
:
stopwords
=
STOPWORDS
if
font_path
is
None
:
font_path
=
FONT_PATH
self
.
font_path
=
font_path
...
...
@@ -213,7 +211,7 @@ class WordCloud(object):
self
.
scale
=
scale
self
.
color_func
=
color_func
self
.
max_words
=
max_words
self
.
stopwords
=
stopwords
self
.
stopwords
=
stopwords
or
STOPWORDS
self
.
min_font_size
=
min_font_size
self
.
font_step
=
font_step
if
isinstance
(
random_state
,
int
):
...
...
@@ -382,7 +380,7 @@ class WordCloud(object):
include all those things.
"""
self
.
stopwords_lower_
=
[
word
.
lower
()
for
word
in
self
.
stopwords
]
self
.
stopwords_lower_
=
set
(
map
(
str
.
lower
,
self
.
stopwords
))
d
=
{}
flags
=
(
re
.
UNICODE
if
sys
.
version
<
'3'
and
type
(
text
)
is
unicode
...
...
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