Skip to content

Commit

Permalink
Add ability to add a dummy entity
Browse files Browse the repository at this point in the history
  • Loading branch information
rafelafrance committed Oct 3, 2024
1 parent df03084 commit b858fe4
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions traiter/pylib/rules/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ def from_ent(cls, ent, **kwargs):
kwargs["_text"] = ent.text
return cls(**kwargs)

@classmethod
def dummy_ent(cls, ent, **kwargs):
kwargs["start"] = kwargs.get("start", ent.start_char)
kwargs["end"] = kwargs.get("end", ent.end_char)
kwargs["_trait"] = kwargs.get("_trait", ent.label_)
kwargs["_text"] = kwargs.get("_text", ent.text)
return cls(**kwargs)

def to_dict(self) -> dict:
return {k: v for k, v in asdict(self).items() if v is not None and k[0] != "_"}

Expand Down

0 comments on commit b858fe4

Please sign in to comment.