Skip to content

Commit

Permalink
CU-8697qfvzz: Allow using alternative category names if/when training…
Browse files Browse the repository at this point in the history
… meta cats through CAT.train_supervised
  • Loading branch information
mart-r committed Feb 24, 2025
1 parent 06978de commit 2b2f259
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions medcat/cat.py
Original file line number Diff line number Diff line change
Expand Up @@ -1094,12 +1094,13 @@ def train_supervised_raw(self,
_, _, ann0 = next(iter_anns(data)) # type: ignore
for meta_cat in self._meta_cats:
# only consider meta-cats that have been defined for the category
# NOTE: as of PR #515 this may become more complicated since it could work
# without this exact match as well
cat_name = meta_cat.config.general.category_name
if 'meta_anns' in ann0 and cat_name in ann0['meta_anns']: # type: ignore
logger.debug("Training MetaCAT %s", meta_cat.config.general.category_name)
meta_cat.train_raw(data)
if 'meta_anns' in ann0:
ann_names = ann0['meta_anns'].keys() # type: ignore
# adapt to alternative names if applicable
cat_name = meta_cat.config.general.get_applicable_category_name(ann_names)
if cat_name in ann_names:
logger.debug("Training MetaCAT %s", meta_cat.config.general.category_name)
meta_cat.train_raw(data)

# reset the state of filters
self.config.linking.filters = orig_filters
Expand Down

0 comments on commit 2b2f259

Please sign in to comment.