Skip to content

Commit

Permalink
Deal with issue where NOT_TRANSLATED values are not correctly excluded
Browse files Browse the repository at this point in the history
  • Loading branch information
matentzn committed Mar 1, 2024
1 parent a79ee1e commit b787f09
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/babelon/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,23 @@ def prepare_translation_for_ontology(
source_value = row["source_value"]
translation_status = row["translation_status"]
term_metadata = _get_metadata_for_term(ontology, subject_id)
if translation_status == "NOT_TRANSLATED":
if not include_not_translated:
mark_index_for_removal.append(index)
if predicate_id in term_metadata:
output_not_translated_data.append(row.to_dict())
else:
logging.warning(
f"{predicate_id} value for {subject_id} is marked as NOT_TRANSLATED,"
f"but does not exist at all in the ontology. Omitting row."
)
if predicate_id in term_metadata:
ontology_value = term_metadata[predicate_id][0]
if len(term_metadata[predicate_id]) > 1:
logging.warning(
f"{predicate_id} value for {subject_id} is ambiguous,"
f"picking first one ({term_metadata[predicate_id]})."
)
if translation_status == "NOT_TRANSLATED":
output_not_translated_data.append(row.to_dict())
if not include_not_translated:
mark_index_for_removal.append(index)
if ontology_value != source_value:
translation_value = row["translation_value"]
df_augmented.at[index, "source_value"] = ontology_value
Expand Down

0 comments on commit b787f09

Please sign in to comment.