add gimme_probabs_multi_lang
this method operates on a list of language probability dictionaries, passes most of the parameters to other instance methods defined earlier
This commit is contained in:
parent
f09d4177c7
commit
bda5b336ed
@ -120,6 +120,31 @@ class da_detector:
|
||||
# a pretty good bogus probability is a one close™ reasonably to zero
|
||||
return [0.000000123 if n is None else n for n in probabilities]
|
||||
|
||||
# return proper probabilities for multiple languages
|
||||
def gimme_probabs_multi_lang(
|
||||
self,
|
||||
langs: list,
|
||||
txt: str,
|
||||
what_grams: int,
|
||||
how_many: int
|
||||
):
|
||||
if len(langs) == 0:
|
||||
# fallback
|
||||
langs = self.langs_to_check
|
||||
|
||||
probabs = []
|
||||
try:
|
||||
for lang in langs:
|
||||
probabs.append(
|
||||
self.gimme_probabilities(
|
||||
lang,
|
||||
self.pick_ngrams(what_grams, how_many, txt)
|
||||
)
|
||||
)
|
||||
except Exception as e:
|
||||
raise e
|
||||
return probabs
|
||||
|
||||
|
||||
freqs_folder = "./freqs/"
|
||||
test_str = "what freaking ever, nobody cares one bit of a heck"
|
||||
|
Reference in New Issue
Block a user