Skip to content

Commit 6117489

Browse files
author
Tom Searle
committed
CU-8698jzjj3: flake8 fixes
1 parent df0080c commit 6117489

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

medcat-v1/medcat/utils/ner/deid.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ def _get_reason_not_deid(cls, cat: CAT) -> str:
190190
return ""
191191

192192

193-
def match_rules(rules: List[Tuple[str, str]], texts: List[str], cat: CAT):
193+
def match_rules(rules: List[Tuple[str, str]], texts: List[str], cat: CAT) -> List[List[Dict]]:
194194
"""Match a set of rules - pat / cui combos as post processing labels.
195195
196196
Uses a cat DeID model for pretty name mapping.
@@ -210,6 +210,9 @@ def match_rules(rules: List[Tuple[str, str]], texts: List[str], cat: CAT):
210210
'My phone number is 1234567890',
211211
]
212212
>>> matches = match_rules(rules, texts, cat)
213+
214+
Returns:
215+
List[List[Dict]]: List of lists of predictions from `match_rules`
213216
"""
214217
# Iterate through each text and pattern combination
215218
rule_matches_per_text = []
@@ -235,7 +238,7 @@ def match_rules(rules: List[Tuple[str, str]], texts: List[str], cat: CAT):
235238

236239
def merge_preds(model_preds_by_text: List[List[Dict]],
237240
rule_matches_per_text: List[List[Dict]],
238-
accept_preds: bool = True):
241+
accept_preds: bool = True) -> List[List[Dict]]:
239242
"""Merge predictions from rule based and deID model predictions.
240243
241244
Args:
@@ -267,6 +270,9 @@ def merge_preds(model_preds_by_text: List[List[Dict]],
267270
]
268271
]
269272
>>> merged_preds = merge_preds(model_preds_by_text, rule_matches_by_text)
273+
274+
Returns:
275+
List[List[Dict]]: List of lists of predictions from `merge_preds`
270276
"""
271277
all_preds = []
272278
if accept_preds:

medcat-v1/medcat/utils/ner/metrics.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ def metrics(p, return_df=False, plus_recall=0, tokenizer=None, dataset=None, mer
2222
return_df: Whether to return a DataFrame of metrics.
2323
plus_recall: The recall to add to the model's predictions.
2424
tokenizer: The tokenizer used to tokenize the texts.
25+
dataset: The dataset used to train the model.
26+
merged_negative: The negative labels to merge.
27+
padding_label: The padding label.
28+
csize: The size of the context window.
29+
subword_label: The subword label.
30+
verbose: Whether to print the metrics.
31+
2532
"""
2633
"""TODO: This could be done better, for sure. But it works.""" # noqa
2734
predictions = np.array(p.predictions)

0 commit comments

Comments
 (0)