medspacy.postprocess.postprocessing_rule
PostprocessingRule
Source code in medspacy/postprocess/postprocessing_rule.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
__call__(ent, i, debug=False)
Iterate through all the rules in self.rules. If any pattern does not pass (ie., return True), then returns False. If they all pass, execute self.action and return True.
Source code in medspacy/postprocess/postprocessing_rule.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | |
__init__(patterns, action, name=None, description=None, span_group_name='medspacy_spans', **kwargs)
A PostprocessingRule checks conditions of a spaCy Span entity and executes some action if all rules are met.
patterns: A list of PostprocessingPatterns, each of which check a condition of an entity.
action: A function to call with the entity as an argument. This function should take the following arguments:
ent: The spacy span
i: The index of ent
input_span_type: "ents" or "group". Describes where to look for spans.
span_group_name: The name of the span group used when input_span_type is "group".
kwargs: Any additional keyword arguments for action.
name: Optional name of direction.
description: Optional description of the direction.
kwargs: Optional keyword arguments to send to action.
Source code in medspacy/postprocess/postprocessing_rule.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | |