Skip to content

Commit

Permalink
#280 related (complete refactoring)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolay-r committed Feb 16, 2022
1 parent f9ad10a commit 1826e58
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions examples/network/text_parser/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ class TextEntitiesParser(BasePipelineItem):

def __init__(self):
super(TextEntitiesParser, self).__init__()
self.__id_in_doc = 0

def apply(self, pipeline_ctx):
assert(isinstance(pipeline_ctx, PipelineContext))

# reset counter.
self.__id_in_doc = 0

# extract terms.
words = pipeline_ctx.provide("src")
assert(isinstance(words, list))
Expand All @@ -27,8 +23,7 @@ def __process_word(self, word):

# If this is a special word which is related to the [entity] mention.
if word[0] == "[" and word[-1] == "]":
entity = Entity(value=word[1:-1], e_type=None, id_in_doc=self.__id_in_doc)
self.__id_in_doc += 1
entity = Entity(value=word[1:-1], e_type=None)
return entity

return word
return word

0 comments on commit 1826e58

Please sign in to comment.