Skip to content

Commit 17938d9

Browse files
author
guoyongzhi
committed
custom profile path
1 parent 58c16ab commit 17938d9

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/detector.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Initialize the language detector with the given parameters. Different parameters
3333
- `cutoff::Float64`: The cutoff value of the cumulative probability of the n-grams to use for language detection. The default value is 0.85, and it must be between 0 and 1.
3434
- `vocabulary::Union{Int, AbstractRange}`: The size range of the vocabulary of each language. The default value is 1000:5000.
3535
"""
36-
function initialize(; languages=supported_languages(), ngram=4, cutoff=0.85, vocabulary=1000:5000)
36+
function initialize(; languages=supported_languages(), ngram=4, cutoff=0.85, vocabulary=1000:5000, path=PROFILE_PATH)
3737
vocabulary = vocabulary isa AbstractRange ? vocabulary : 1:vocabulary
3838
ngram = ngram isa AbstractVector ? ngram : 1:ngram
3939
empty!(NGRAM)
@@ -42,7 +42,7 @@ function initialize(; languages=supported_languages(), ngram=4, cutoff=0.85, voc
4242
append!(LANGUAGES, languages)
4343
empty!(PROFILES)
4444
for lang in LANGUAGES
45-
push!(PROFILES, load_profile(lang, NGRAM, cutoff, vocabulary))
45+
push!(PROFILES, load_profile(lang, NGRAM, cutoff, vocabulary; path=path))
4646
end
4747
unk_decay = 0.01
4848
for P in PROFILES
@@ -59,9 +59,9 @@ function makesure_initialized()
5959
end
6060
end
6161

62-
function load_profile(lang, ngram_list::AbstractVector, cutoff, vocabularyrange)
62+
function load_profile(lang, ngram_list::AbstractVector, cutoff, vocabularyrange; path=PROFILE_PATH)
6363
vocmin, vocmax = first(vocabularyrange), last(vocabularyrange)
64-
hd, rows = ngram_table(joinpath(PROFILE_PATH, lang * ".txt"))
64+
hd, rows = ngram_table(joinpath(path, lang * ".txt"))
6565
total = sum(hd[ngram_list])
6666
threshold = cutoff * total
6767
cums = 0.0

0 commit comments

Comments
 (0)