Skip to content

Commit da0906f

Browse files
author
guoyongzhi
committed
set to state placement! when unfitted
1 parent f119b54 commit da0906f

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "WordCloud"
22
uuid = "6385f0a0-cb03-45b6-9089-4e0acc74b26b"
33
authors = ["guoyongzhi <momoshanghan@163.com>"]
4-
version = "0.6.9"
4+
version = "0.6.10"
55

66
[deps]
77
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"

src/rendering.jl

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ function load(fn)
3636
end
3737

3838
function svg2bitmap(svg::Drawing)
39-
d = Drawing(svg.width, svg.height, :image)
39+
Drawing(svg.width, svg.height, :image)
4040
placeimage(svg)
41-
m=image_as_matrix()
41+
m = image_as_matrix()
4242
finish()
4343
m
4444
end
@@ -195,8 +195,6 @@ function overlay(color1::T, color2::T) where {T}
195195
end
196196
"put img2 on img1 at (x, y)"
197197
function overlay!(img1::AbstractMatrix, img2::AbstractMatrix, x=1, y=1)#左上角重合时(x=1,y=1)
198-
h1, w1 = size(img1)
199-
h2, w2 = size(img2)
200198
img1v, img2v = overlappingarea(img1, img2, x, y)
201199
# @show (h1, w1),(h2, w2),(x,y)
202200
img1v .= overlay.(img1v, img2v)

src/wc-method.jl

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ end
2121
initimages!(wc, i; kargs...) = initimage!.(wc, index(wc, i); kargs...)
2222
function initimages!(wc::WC; maxiter=5, error=0.02)
2323
params = wc.params
24-
mask = wc.mask
2524

2625
si = sortperm(wc.weights, rev=true)
2726
words = wc.words[si]
@@ -151,7 +150,14 @@ function recolor!(wc, args...; style=:average, kargs...)
151150
end
152151
nothing
153152
end
154-
153+
"""
154+
# Positional Args
155+
* wc: the wordcloud to fit
156+
* nepoch: training epoch nums
157+
# Keyword Args
158+
* patient: number of epochs before teleporting, set to `-1` to disable teleporting
159+
* trainer: appoint a training engine
160+
"""
155161
function fit!(wc, args...; krags...)
156162
if STATEIDS[getstate(wc)] < STATEIDS[:placement!]
157163
placement!(wc)
@@ -161,6 +167,8 @@ function fit!(wc, args...; krags...)
161167
wc.params[:epoch] += ep
162168
if nc == 0
163169
setstate!(wc, nameof(fit!))
170+
else
171+
setstate!(wc, nameof(placement!))
164172
end
165173
wc
166174
end
@@ -177,7 +185,7 @@ function printcollisions(wc)
177185
end
178186
"""
179187
# Positional Args
180-
* wc: the wordcloud to train
188+
* wc: the wordcloud to fit
181189
* nepoch: training epoch nums
182190
# Keyword Args
183191
* retry: shrink & retrain times, defaults to 3, set to `1` to disable shrinking
@@ -188,11 +196,9 @@ function generate!(wc::WC, args...; retry=3, krags...)
188196
if STATEIDS[getstate(wc)] < STATEIDS[:placement!]
189197
placement!(wc)
190198
end
191-
ep, nc = -1, -1
192199
for r in 1:retry
193200
if r != 1
194201
rescale!(wc, 0.97)
195-
qtrees = [wc.maskqtree, wc.qtrees...]
196202
dens = textoccupied(getwords(wc), getfontsizes(wc), getfonts(wc))/wc.params[:groundoccupied]
197203
println("#$r. try scale = $(wc.params[:scale]). The density is reduced to $dens")
198204
else

0 commit comments

Comments
 (0)