Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
vmenger committed Dec 1, 2023
1 parent 280e7a8 commit f4d21ef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
13 changes: 7 additions & 6 deletions docdeid/process/annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,13 @@ def __init__(
self._matching_pipeline = matching_pipeline or []

self._trie = LookupTrie(matching_pipeline=matching_pipeline)
self._start_texts = set()
self._start_texts: set[str] = set()

self._init_lookup_structures(lookup_values, tokenizer)

super().__init__(*args, **kwargs)

def _init_lookup_structures(self, lookup_values: Iterable[str], tokenizer: Tokenizer):
def _init_lookup_structures(self, lookup_values: Iterable[str], tokenizer: Tokenizer) -> None:

for val in lookup_values:

Expand Down Expand Up @@ -232,10 +232,11 @@ def __init__(
self.regexp_pattern = regexp_pattern
self.capturing_group = capturing_group

self.pre_tokens = pre_match_tokens
self.pre_match_tokens: Optional[set[str]] = None
self.matching_pipeline: Optional[list[StringModifier]] = None

if pre_match_tokens is not None:
self.pre_tokens = set(pre_match_tokens)
self.pre_match_tokens = set(pre_match_tokens)
self.matching_pipeline = [docdeid.str.LowercaseString()]

super().__init__(*args, **kwargs)
Expand All @@ -245,9 +246,9 @@ def _validate_match(self, match: re.Match, doc: Document) -> bool:

def annotate(self, doc: Document) -> list[Annotation]:

if self.pre_tokens is not None:
if self.pre_match_tokens is not None:
try:
if doc.get_tokens().get_words(self.matching_pipeline).isdisjoint(self.pre_tokens):
if doc.get_tokens().get_words(self.matching_pipeline).isdisjoint(self.pre_match_tokens):
return []
except RuntimeError:
pass
Expand Down
2 changes: 1 addition & 1 deletion docdeid/str/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def process_items(self, items: Iterable[str]) -> list[str]:
The processed items.
"""

def __repr__(self):
def __repr__(self) -> str:
return self.__class__.__name__ + "(" + ", ".join(f"{k}={v}" for k, v in self.__dict__.items()) + ")"


Expand Down

0 comments on commit f4d21ef

Please sign in to comment.