add a "try" wrapper for when getting probabs
This commit is contained in:
parent
789ccd5856
commit
f09d4177c7
@ -104,9 +104,13 @@ class da_detector:
|
|||||||
|
|
||||||
# may contain None values if not found, hence uncleansed
|
# may contain None values if not found, hence uncleansed
|
||||||
uncleansed_probabilities = []
|
uncleansed_probabilities = []
|
||||||
for ngram in ngrams:
|
try:
|
||||||
uncleansed_probabilities.append(lang_probs.get(ngram))
|
for ngram in ngrams:
|
||||||
return self.replace_nones(uncleansed_probabilities)
|
uncleansed_probabilities.append(lang_probs.get(ngram))
|
||||||
|
cleansed_probabs = self.replace_nones(uncleansed_probabilities)
|
||||||
|
except Exception as e:
|
||||||
|
raise e
|
||||||
|
return cleansed_probabs
|
||||||
|
|
||||||
def replace_nones(self, probabilities: list):
|
def replace_nones(self, probabilities: list):
|
||||||
if not isinstance(probabilities, list):
|
if not isinstance(probabilities, list):
|
||||||
|
Reference in New Issue
Block a user