From 5420b74e108151568f6cfe13d1a57df2105991ea Mon Sep 17 00:00:00 2001 From: Nicolay Rusnachenko Date: Fri, 25 Nov 2022 12:11:17 +0300 Subject: [PATCH] #418 switched to display_value. #416 related. Now we don't modify the oriainal value, since it affects on the `SynonymsCollection` behavior. --- arekit/common/entities/base.py | 14 +++++++++----- .../utils/pipelines/items/text/translator.py | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/arekit/common/entities/base.py b/arekit/common/entities/base.py index ab6b7830..3eead061 100644 --- a/arekit/common/entities/base.py +++ b/arekit/common/entities/base.py @@ -7,7 +7,7 @@ def __init__(self, value, e_type, group_index=None): self.__value = value.lower() self.__type = e_type self.__group_index = group_index - self.__caption = None + self.__display_value = None @property def GroupIndex(self): @@ -15,21 +15,25 @@ def GroupIndex(self): @property def Value(self): + return self.__value + + @property + def DisplayValue(self): """ Now, we consider the default value in case - of the undefined caption, and caption otherwise. + of the undefined caption, and display_value otherwise. """ - return self.__value if self.__caption is None else self.__caption + return self.__value if self.__display_value is None else self.__display_value @property def Type(self): return self.__type - def set_caption(self, caption): + def set_display_value(self, caption): """ Caption allows to customize the original value. Required for optional value modification. """ assert(isinstance(caption, str)) - self.__caption = caption + self.__display_value = caption def set_group_index(self, value): assert(isinstance(value, int) and value >= -1) diff --git a/arekit/contrib/utils/pipelines/items/text/translator.py b/arekit/contrib/utils/pipelines/items/text/translator.py index 76c48c4b..302a18d5 100644 --- a/arekit/contrib/utils/pipelines/items/text/translator.py +++ b/arekit/contrib/utils/pipelines/items/text/translator.py @@ -54,7 +54,7 @@ def __optionally_register(prts_to_join): for entity_ind, entity_part_ind in enumerate(origin_entity_ind): entity = origin_entities[entity_ind] - entity.set_caption(translated_parts[entity_part_ind]) + entity.set_display_value(translated_parts[entity_part_ind]) translated_parts[entity_part_ind] = entity return translated_parts