Skip to content
Snippets Groups Projects
Commit 9bcc5e59 authored by Paweł Walkowiak's avatar Paweł Walkowiak
Browse files

Add try-except

parent d62da8a9
No related branches found
No related tags found
1 merge request!13Fix anonymizer errors
Pipeline #15156 failed
......@@ -92,9 +92,11 @@ class NERFileMorphosyntacticDictionary(MorphosyntacticDictionary):
if original_entry_type_name in self._dictionary:
entry_type = original_entry_type_name
if morpho_tag in self._dictionary[entry_type] \
and morpho_tag in self._dictionary[entry_type]:
try:
if entry_type in self._dictionary \
and morpho_tag in self._dictionary[entry_type] \
and len(list(self._dictionary[
entry_type][morpho_tag].keys())) > 0:
lemma = random.choice(
list(self._dictionary[entry_type][morpho_tag].keys())
)
......@@ -108,6 +110,10 @@ class NERFileMorphosyntacticDictionary(MorphosyntacticDictionary):
list(self._dictionary[entry_type][morpho_tag].keys())
)
word = lemma
except IndexError as exp:
print(f"IndexError entry_type {entry_type} morpho_tag {morpho_tag}")
print(exp)
print(f"Dictionary {self._dictionary[entry_type][morpho_tag]}")
if word is None and self._always_replace:
entry_type = random.choice(list(self._dictionary.keys()))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment