Skip to content

Commit c527f7a

Browse files
committed
set random font by language
1 parent 21831e2 commit c527f7a

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
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 <guo-yong-zhi@outlook.com>"]
4-
version = "0.13.4"
4+
version = "0.13.5"
55

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

src/textprocessing.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module TextProcessing
2-
export countwords, processtext, html2text, STOPWORDS, casemerge!, rescaleweights, settokenizer!, setlemmatizer!, setstopwords!
2+
export countwords, processtext, html2text, STOPWORDS, casemerge!, rescaleweights, settokenizer!, setlemmatizer!, setstopwords!, detect_language
33

44
using StopWords
55
using LanguageIdentification

src/wc-class.jl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ wordcloud(wordsweights::Tuple; kargs...) = wordcloud(wordsweights...; kargs...)
7373
wordcloud(counter::AbstractDict; kargs...) = wordcloud(keys(counter) |> collect, values(counter) |> collect; kargs...)
7474
wordcloud(counter::AbstractVector{<:Union{Pair,Tuple,AbstractVector}}; kargs...) = wordcloud(first.(counter), [v[2] for v in counter]; kargs...)
7575
function wordcloud(text; language=:auto, stopwords=:auto, stopwords_extra=nothing, maxnum=500, kargs...)
76+
language = detect_language(text, language)
7677
wordcloud(processtext(text, language=language, stopwords=stopwords, stopwords_extra=stopwords_extra, maxnum=maxnum); language=language, kargs...)
7778
end
7879
wordcloud(words, weight::Number; kargs...) = wordcloud(words, repeat([weight], length(words)); kargs...)
@@ -249,8 +250,7 @@ function getstylescheme(words, weights; colors=:auto, angles=:auto, mask=:auto,
249250
Render.recolor!(mask, maskcolor) # tobitmap后有杂色 https://github.com/JuliaGraphics/Luxor.jl/issues/160
250251
end
251252
end
252-
lang = language in DEFAULTSYMBOLS ? "" : language
253-
fonts in DEFAULTSYMBOLS && (fonts = randomfonts(lang))
253+
fonts in DEFAULTSYMBOLS && (fonts = randomfonts(detect_language(words, language)))
254254
fonts = Iterators.take(iter_expand(fonts), length(words)) |> collect
255255
colors, angles, mask, svgmask, fonts, transparent
256256
end

0 commit comments

Comments
 (0)