Skip to content

Commit

Permalink
#502 related fix in order to be compatible with RowsParsing and reading
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolay-r committed Sep 27, 2023
1 parent e72540e commit b84d545
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions arekit/contrib/utils/data/writers/json_opennre.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ class OpenNREJsonWriter(BaseWriter):
During the dataset reading stage via OpenNRE, these linkages automaticaly groups into bags.
"""

EXTRA_KEYS_TEMPLATE = "_{}"

def __init__(self, text_columns, encoding="utf-8", na_value="NA", keep_extra_columns=True):
""" text_columns: list
column names that expected to be joined into a single (token) column.
Expand Down Expand Up @@ -75,7 +73,10 @@ def __format_row(row, na_value, text_columns, keep_extra_columns):
if keep_extra_columns:
for key, value in row.items():
if key not in formatted_data and key not in text_columns:
formatted_data[OpenNREJsonWriter.EXTRA_KEYS_TEMPLATE.format(key)] = value
formatted_data[key] = value
else:
raise Exception(f"key `{key}` is already exist in formatted data "
f"or a part of the text columns list: f{text_columns}")

return formatted_data

Expand Down

0 comments on commit b84d545

Please sign in to comment.