mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Ensure token probability is less than 1.0
This commit is contained in:
@@ -129,10 +129,10 @@ module Linguist
|
|||||||
#
|
#
|
||||||
# Returns Float between 0.0 and 1.0.
|
# Returns Float between 0.0 and 1.0.
|
||||||
def token_probability(token, language)
|
def token_probability(token, language)
|
||||||
if @tokens[language][token] == 0
|
if @tokens[language][token].to_f == 0.0
|
||||||
1 / @tokens_total.to_f
|
1 / @tokens_total.to_f
|
||||||
else
|
else
|
||||||
@tokens[language][token].to_f / @languages[language].to_f
|
@tokens[language][token].to_f / @language_tokens[language].to_f
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user