Skip to content

Commit 6318198

Browse files
author
guoyongzhi
committed
change the meaning of the range arg
1 parent bdf534d commit 6318198

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/detector.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ Initialize the language detector with the given parameters. Different parameters
2929
3030
# Arguments
3131
- `languages::Vector{String}`: A list of languages to be used for language detection. If this argument is not provided, all the languages returned by the [`supported_languages`](@ref) function will be used.
32-
- `ngram::Union{Int, AbstractVector}`: The length of utf-8 byte n-grams to use for language detection. A range can be provided to use multiple n-gram sizes. An integer value will be converted to a range from 1 to the given value. The default value is 4.
32+
- `ngram::Union{Int, AbstractVector}`: Specifies the length of UTF-8 byte n-grams to be utilized for language detection. An integer value can be provided to use a single n-gram size, while a range can be provided to use multiple n-gram sizes. The default value is 1:4, and the maximum value allowed is 7.
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, path=PROFILE_PATH)
37-
vocabulary = vocabulary isa AbstractRange ? vocabulary : 1:vocabulary
38-
ngram = ngram isa AbstractVector ? ngram : 1:ngram
36+
function initialize(; languages=supported_languages(), ngram=1:4, cutoff=0.85, vocabulary=1000:5000, path=PROFILE_PATH)
37+
vocabulary = vocabulary isa AbstractRange ? vocabulary : vocabulary:vocabulary
38+
ngram = ngram isa AbstractVector ? ngram : ngram:ngram
3939
empty!(NGRAM)
4040
append!(NGRAM, ngram)
4141
empty!(LANGUAGES)

src/ngrams.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ function count_all_ngrams(text::AbstractString, rg::AbstractVector=1:5, counter=
3131
counter
3232
end
3333
function count_all_ngrams(text::AbstractString, n::Int, counter=Dict{Vector{UInt8},Float32}(); kwargs...)
34-
count_all_ngrams(text, 1:n, counter; kwargs...)
34+
count_all_ngrams(text, n:n, counter; kwargs...)
3535
end
3636
function count_all_ngrams(text_list, n, counter = Dict{Vector{UInt8},Float32}(); kwargs...)
3737
for text in text_list

0 commit comments

Comments
 (0)