diff --git a/anonipy/anonymize/extractors/pattern_extractor.py b/anonipy/anonymize/extractors/pattern_extractor.py index 266b554..385fb7d 100644 --- a/anonipy/anonymize/extractors/pattern_extractor.py +++ b/anonipy/anonymize/extractors/pattern_extractor.py @@ -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 @@ -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 \ No newline at end of file