add a "try" wrapper for when getting probabs

This commit is contained in:
surtur 2021-12-20 01:36:44 +01:00
parent 789ccd5856
commit f09d4177c7
Signed by: wanderer
GPG Key ID: 19CE1EC1D9E0486D

@ -104,9 +104,13 @@ class da_detector:
# may contain None values if not found, hence uncleansed
uncleansed_probabilities = []
try:
for ngram in ngrams:
uncleansed_probabilities.append(lang_probs.get(ngram))
return self.replace_nones(uncleansed_probabilities)
cleansed_probabs = self.replace_nones(uncleansed_probabilities)
except Exception as e:
raise e
return cleansed_probabs
def replace_nones(self, probabilities: list):
if not isinstance(probabilities, list):