Skip to content

Commit

Permalink
updated formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
LydiaMennesHealth committed Jan 17, 2024
1 parent 71339b7 commit e198630
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
4 changes: 2 additions & 2 deletions docdeid/process/doc_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ def __iter__(self) -> Iterator:

def iter_doc_processors(self) -> Iterator[DocProcessor]:
"""
Iterate over all document processors in this group.
Uses recursion for encountered :class:`.DocProcessorGroup`.
Iterate over all document processors in this group. Uses recursion for
encountered :class:`.DocProcessorGroup`.
Yields:
The document processors.
Expand Down
18 changes: 13 additions & 5 deletions docdeid/str/expander.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class Expander(ABC):
@abstractmethod
def expand_item(self, item: str) -> set[str]:
"""
Expand a string into a list of strings that contains the original and possibly additional strings.
Expand a string into a list of strings that contains the original and possibly
additional strings.
Args:
items: The input item.
Expand All @@ -21,7 +22,8 @@ def expand_item(self, item: str) -> set[str]:

def expand_item_iterable(self, items: Iterable[str]) -> set[str]:
"""
Expand a set of strings into a set of strings that contains the original and possibly additional strings.
Expand a set of strings into a set of strings that contains the original and
possibly additional strings.
Args:
words: The input set of strings.
Expand All @@ -32,7 +34,8 @@ def expand_item_iterable(self, items: Iterable[str]) -> set[str]:
return set.union(*(self.expand_item(item) for item in items))

def get_expansion_to_original_dict(self, items: Iterable[str]) -> dict[str, str]:
"""Expand a set of strings into a dictionary where the keys are results from expand_item and values the original text."""
"""Expand a set of strings into a dictionary where the keys are results from
expand_item and values the original text."""

# This can get overwritten if different original texts map to the same expansion due to multiple operations...
result_dict = {}
Expand All @@ -43,7 +46,11 @@ def get_expansion_to_original_dict(self, items: Iterable[str]) -> dict[str, str]


class MinimumLengthExpander(Expander):
"""Expands a string by applying the lists of string processors. These are only applied to tokens whose length >= minimum length"""
"""
Expands a string by applying the lists of string processors.
These are only applied to tokens whose length >= minimum length
"""

def __init__(
self, str_modifiers: list[StringModifier], min_length: int = 5
Expand All @@ -53,7 +60,8 @@ def __init__(

def expand_item(self, item: str) -> set[str]:
"""
Expand a string by adding versions for each string processor if the length surpasses the minimum.
Expand a string by adding versions for each string processor if the length
surpasses the minimum.
Args:
item: The input item.
Expand Down

0 comments on commit e198630

Please sign in to comment.