Skip to content

Commit

Permalink
fix: Added support for doc entities
Browse files Browse the repository at this point in the history
  • Loading branch information
KennethEnevoldsen committed May 4, 2023
1 parent faf2abc commit 6ca5439
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/augmenty/span/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@

import numpy as np
from spacy.language import Language
from spacy.tokens import Span, Token
from spacy.tokens import Doc, Span, Token
from spacy.training import Example
from spacy.util import registry

from ..augment_utilities import make_text_from_orth

# create entity type
ENTITY = Union[str, List[str], Span]
ENTITY = Union[str, List[str], Span, Doc]


def __normalize_entity(entity: ENTITY, nlp: Language) -> Dict[str, List[Any]]:
Expand All @@ -37,7 +37,7 @@ def __normalize_entity(entity: ENTITY, nlp: Language) -> Dict[str, List[Any]]:
spacy = [tok.whitespace_ for tok in ent_doc]
elif isinstance(entity, list):
orth = entity
elif isinstance(entity, Span):
elif isinstance(entity, (Span, Doc)):
orth = [tok.text for tok in entity]
spacy = [tok.whitespace_ for tok in entity]
pos = [tok.pos_ for tok in entity]
Expand Down

0 comments on commit 6ca5439

Please sign in to comment.