Skip to content

Commit

Permalink
Use create_spacy_entities
Browse files Browse the repository at this point in the history
  • Loading branch information
ninakokalj committed Dec 17, 2024
1 parent 58f8dcc commit 706e9e7
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions anonipy/anonymize/extractors/pattern_extractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,9 @@ def global_matchers(doc: Doc) -> None:
if not entity:
continue
entity._.score = 1.0
entities = [convert_spacy_to_entity(entity)]
# add the entity to the previous entity list
prev_entities = get_doc_entity_spans(doc, self.spacy_style)
if self.spacy_style == "ent":
prev_entities = util.filter_spans(prev_entities + (entity,))
elif self.spacy_style == "span":
prev_entities.append(entity)
else:
raise ValueError(f"Invalid spacy style: {self.spacy_style}")
set_doc_entity_spans(doc, prev_entities, self.spacy_style)
create_spacy_entities(doc, entities, self.spacy_style)

return global_matchers

Expand Down Expand Up @@ -250,8 +244,8 @@ def add_event_ent(matcher, doc, i, matches):
entity = Span(doc, start, end, label=label)
if not entity:
return
entity._.score = 1.0
entities = [convert_spacy_to_entity(entity)]

create_spacy_entities(doc, entities, self.spacy_style)

return add_event_ent

0 comments on commit 706e9e7

Please sign in to comment.