pat2vec.util.methods_get_medcatο
Functions
|
Loads and returns a MedCAT model instance based on configuration. |
- pat2vec.util.methods_get_medcat.get_cat(config_obj)[source]ο
Loads and returns a MedCAT model instance based on configuration.
This function determines which MedCAT model to load based on the provided
configuration object. It supports several loading strategies:
Dummy Model: If config_obj.testing and config_obj.dummy_medcat_model are True, it returns a dummy_CAT instance for testing without a real model.
Automatic Path Detection: If config_obj.override_medcat_model_path is set to βautoβ, it searches sys.path for a medcat_models directory and loads the first .zip model pack found.
Explicit Path: It checks for a model path in this order: a. medcat_path variable imported from a local paths.py file. b. config_obj.override_medcat_model_path.
No Model: If config_obj.medcat is False, it returns None.
- Parameters:
config_obj (
Any) β The configuration object containing settings like testing, medcat, and model paths.- Return type:
Union[CAT,dummy_CAT,None]- Returns:
An instance of a MedCAT CAT object, a dummy_CAT object for testing, or None if MedCAT processing is disabled.
- Raises:
ValueError β If MedCAT is enabled but no valid model path can be found. # type: ignore