medspacy icon indicating copy to clipboard operation
medspacy copied to clipboard

TargetRule wrong type for pattern?

Open jmugan opened this issue 3 years ago • 1 comments

Here https://github.com/medspacy/medspacy/blob/master/medspacy/target_matcher/target_rule.py it lists the type for pattern as pattern: Optional[Union[List[Dict[str, str]], str]] = None,.

But in spacy the dicts can have dicts. Here's my rule:

TargetRule("billybob", "SEABASS",
               pattern=[{"LOWER": {"IN": ["taco","hotdog"]}}])

In this case, pattern is List[Dict[str,Dict]]. So maybe it should be changed to

pattern: Optional[Union[List[Dict[str, Union[Dict,str]]], str]] = None

or since that is pretty hard to read, maybe just

pattern: Optional[Union[List[Dict], str]] = None

jmugan avatar Nov 30 '22 01:11 jmugan

agree

jianlins avatar Feb 10 '23 20:02 jianlins