Skip to content

Commit 08f1fd7

Browse files
authored
CU-8699q97m0 Fix supervised train negative examples (#37)
* CU-8699q97m0: Fix negative examples in supervised training data * CU-8699q97m0: Show better exceptions for KeyError when doing supervised training
1 parent 857f97b commit 08f1fd7

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

medcat-v2/medcat/components/linking/vector_context_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ def train(self, cui: str, entity: MutableEntity, doc: MutableDocument,
344344
if name not in self.name2info:
345345
continue
346346
per_cui_status = self.name2info[name]['per_cui_status']
347-
cui_status = per_cui_status[cui]
347+
cui_status = per_cui_status.get(cui, None)
348348
if cui_status == ST.PRIMARY_STATUS_NO_DISAMB:
349349
# Set this name to always be disambiguated, even
350350
# though it is primary

medcat-v2/medcat/trainer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ def _train_supervised_for_project2(self,
438438
cui=cui, name=ann['value'], mut_doc=mut_doc,
439439
mut_entity=mut_entity, negative=deleted,
440440
devalue_others=devalue_others)
441-
except ValueError as ve:
441+
except (ValueError, KeyError) as ve:
442442
context_window = 20 # characters
443443
splitter_left, splitter_right = "<", ">"
444444
cur_text = doc['text']

0 commit comments

Comments
 (0)