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
54b7bdef
Commit
54b7bdef
authored
May 10, 2015
by
Andreas Mueller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add font min_size and font_step to speed up everything.
parent
15b3bf90
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
6 deletions
+17
-6
wordcloud/wordcloud.py
wordcloud/wordcloud.py
+17
-6
No files found.
wordcloud/wordcloud.py
View file @
54b7bdef
...
...
@@ -131,6 +131,14 @@ class WordCloud(object):
using scale instead of larger canvas size is significantly faster, but
might lead to a coarser fit for the words.
min_size : int (default=4)
Smallest font size to use. Will stop when there is no more room in this
size.
font_step : int (default=2)
Step size for the font. font_step=1 might give a better fit but is
somewhat slower.
max_words : number (default=200)
The maximum number of words.
...
...
@@ -165,8 +173,9 @@ class WordCloud(object):
def
__init__
(
self
,
font_path
=
None
,
width
=
400
,
height
=
200
,
margin
=
5
,
ranks_only
=
False
,
prefer_horizontal
=
0.9
,
mask
=
None
,
scale
=
1
,
color_func
=
random_color_func
,
max_words
=
200
,
stopwords
=
None
,
random_state
=
None
,
background_color
=
'black'
,
max_font_size
=
None
):
color_func
=
random_color_func
,
max_words
=
200
,
min_size
=
5
,
stopwords
=
None
,
random_state
=
None
,
background_color
=
'black'
,
max_font_size
=
None
,
font_step
=
2
):
if
stopwords
is
None
:
stopwords
=
STOPWORDS
if
font_path
is
None
:
...
...
@@ -182,6 +191,8 @@ class WordCloud(object):
self
.
color_func
=
color_func
self
.
max_words
=
max_words
self
.
stopwords
=
stopwords
self
.
min_size
=
min_size
self
.
font_step
=
font_step
if
isinstance
(
random_state
,
int
):
random_state
=
Random
(
random_state
)
self
.
random_state
=
random_state
...
...
@@ -245,8 +256,8 @@ class WordCloud(object):
else
:
boolean_mask
=
None
height
,
width
=
self
.
height
,
self
.
width
#
occupancy = IntegralOccupancyMap(height, width, boolean_mask)
occupancy
=
SeparableConvolutionMap
(
height
,
width
,
boolean_mask
)
occupancy
=
IntegralOccupancyMap
(
height
,
width
,
boolean_mask
)
#
occupancy = SeparableConvolutionMap(height, width, boolean_mask)
# create image
img_grey
=
Image
.
new
(
"L"
,
(
width
,
height
))
...
...
@@ -281,9 +292,9 @@ class WordCloud(object):
if
result
is
not
None
or
font_size
==
0
:
break
# if we didn't find a place, make font smaller
font_size
-=
1
font_size
-=
self
.
font_step
if
font_size
==
0
:
if
font_size
<
self
.
min_size
:
# we were unable to draw any more
break
...
...
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