Skip to content
This repository was archived by the owner on Jul 28, 2025. It is now read-only.

Commit 874954e

Browse files
Adding comments
1 parent f72fc28 commit 874954e

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

medcat/utils/meta_cat/data_utils.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ def encode_category_values(data: Dict, existing_category_value2id: Optional[Dict
190190
# If categoryvalue2id is pre-defined, then making sure it is same as the labels found in the data
191191
if len(category_value2id) != 0:
192192
if set(category_value2id.keys()) != category_values:
193+
# if categoryvalue2id doesn't match the labels in the data, then 'class_name_map' has to be defined to check for variations
193194
if len(class_name_map) != 0:
194195
updated_category_value2id = {}
195196
for _class in category_value2id.keys():
@@ -201,11 +202,12 @@ def encode_category_values(data: Dict, existing_category_value2id: Optional[Dict
201202
class_name_matched = [label for label in found_in if label in category_values][0]
202203
updated_category_value2id[class_name_matched] = category_value2id[_class]
203204
logger.warning("Class name '%s' does not exist in the data; however a variation of it '%s' is present; updating it...",_class,class_name_matched)
204-
205205
else:
206206
raise Exception(f"The classes set in the config are not the same as the one found in the data. The classes present in the config vs the ones found in the data - {set(category_value2id.keys())}, {category_values}")
207207
category_value2id = copy.deepcopy(updated_category_value2id)
208208
logger.info("Updated categoryvalue2id mapping - %s", category_value2id)
209+
210+
# Else throw an exception since the labels don't match
209211
else:
210212
raise Exception(
211213
f"The classes set in the config are not the same as the one found in the data. The classes present in the config vs the ones found in the data - {set(category_value2id.keys())}, {category_values}")

0 commit comments

Comments
 (0)