Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DocumentEntityID Assignation -- code parts are implicitly sinchronized with implementation #515

Closed
Tracked by #495
nicolay-r opened this issue Aug 17, 2023 · 1 comment

Comments

@nicolay-r
Copy link
Owner

nicolay-r commented Aug 17, 2023

How to fix: So in a snippet №2 we can use the entities mapping.

The reason is because the code below executed before:

def init_parsed_news(self, parsed_news):
assert(isinstance(parsed_news, ParsedNews))
self._doc_entities = []
self.__entity_map.clear()
for index, entity in enumerate(parsed_news.iter_entities()):
doc_entity = DocumentEntity(id_in_doc=index,
value=entity.Value,
e_type=entity.Type,
display_value=entity.DisplayValue,
group_index=entity.GroupIndex)
self._doc_entities.append(doc_entity)
if self.__entity_index_func is not None:
self.__entity_map[self.__entity_index_func(entity)] = doc_entity

and then followed by this function in the inherited class:

def __calculate_entity_positions(self):
""" Note: here we consider the same order as in self._entities.
"""
positions = []
t_ind_in_doc = 0
for s_ind, t_ind_in_sent, term in self.__iter_raw_terms_func():
if isinstance(term, Entity):
position = TermPosition(term_ind_in_doc=t_ind_in_doc,
term_ind_in_sent=t_ind_in_sent,
s_ind=s_ind)
positions.append(position)
t_ind_in_doc += 1
return positions

Both are about assigning identifiers.
However, when it comes to nested entities, this is expected to be sinchronized in a single place

@nicolay-r
Copy link
Owner Author

Fixed in 8c1ee11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant