medcat.utils.registry
Classes:
Attributes:
MedCATRegistryException
MedCATRegistryException(*args: object)
Bases: Exception
Source code in medcat-v2/medcat/utils/registry.py
211 212 | |
Registry
Methods:
-
get_component–Get the component that's registered.
-
list_components–List all available component names and class names.
-
register– -
register_all_defaults–Register all default (lazily-added) components.
-
register_lazy–Register the component lazily.
-
translate_name–Translate creator / initialiser name.
-
unregister_all_components–Unregister all components.
-
unregister_component–Unregister a component.
-
unregister_component_lazy–Unregister a lazy component.
Source code in medcat-v2/medcat/utils/registry.py
12 13 14 15 16 17 | |
get_component
get_component(component_name: str) -> Callable[..., P]
Get the component that's registered.
The component generally refers to the class, but may be another method that creates the object needed.
Parameters:
-
(component_namestr) –The name of the component.
Raises:
-
MedCATRegistryException–If no component by requested name is registered.
Returns:
Source code in medcat-v2/medcat/utils/registry.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 | |
list_components
List all available component names and class names.
Returns:
-
list[tuple[str, str]]–list[tuple[str, str]]: The list of the names and class names for each registered componetn.
Source code in medcat-v2/medcat/utils/registry.py
140 141 142 143 144 145 146 147 148 149 150 151 | |
register
Source code in medcat-v2/medcat/utils/registry.py
19 20 21 22 23 24 25 | |
register_all_defaults
register_all_defaults() -> None
Register all default (lazily-added) components.
Source code in medcat-v2/medcat/utils/registry.py
108 109 110 111 | |
register_lazy
register_lazy(component_name: str, module_path: str, creator_name: str) -> None
Register the component lazily.
This allows registration without the need to load component internals. However, we do not do any prior way of checking to make sure that these paths are correct.
For instance if your class MySpecialNER is in the module
my_addon.my_module and uses the class method
create_new_component to initialise (thus the complete path is
my_addon.my_module.MySpecialNER.create_new_component) we
would expect the following arguments:
component_name="my_special_ner",
module_path="my_addon.my_module",
creator_name="MySpecialNER.create_new_component"
Parameters:
-
(component_namestr) –The component name.
-
(module_pathstr) –The module name.
-
(creator_namestr) –The creator path.
Raises:
-
MedCATRegistryException–If a component by this name has already been registered.
Source code in medcat-v2/medcat/utils/registry.py
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
translate_name
classmethod
translate_name(initialiser: Callable[..., P]) -> str
Translate creator / initialiser name.
This method will return the method name. Or this is a bound method, it'll return the class name along with the method name (Class.method)
Parameters:
Returns:
-
str(str) –The resulting name
Source code in medcat-v2/medcat/utils/registry.py
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 | |
unregister_all_components
unregister_all_components() -> None
Unregister all components.
Source code in medcat-v2/medcat/utils/registry.py
196 197 198 199 | |
unregister_component
unregister_component(component_name: str) -> Callable[..., P]
Unregister a component.
Parameters:
-
(component_namestr) –The component name.
Raises:
-
MedCATRegistryException–If no component by the name specified had been registered.
Returns:
Source code in medcat-v2/medcat/utils/registry.py
153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
unregister_component_lazy
unregister_component_lazy(component_name: str) -> tuple[str, str]
Unregister a lazy component.
Parameters:
-
(component_namestr) –The component name.
Raises:
-
MedCATRegistryException–If no component by the name specified had been registered.
Returns:
Source code in medcat-v2/medcat/utils/registry.py
174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 | |