:py:mod:`medcat.utils.ner.model` ================================ .. py:module:: medcat.utils.ner.model Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: medcat.utils.ner.model.NerModel .. py:class:: NerModel(cat) The NER model. This wraps a CAT instance and simplifies its use as a NER model. It provides methods for creating one from a TransformersNER as well as loading from a model pack (along with some validation). It also exposes some useful parts of the CAT it wraps such as the config and the concept database. .. py:property:: config :type: medcat.config.Config .. py:property:: cdb :type: medcat.cdb.CDB .. py:method:: __init__(cat) .. py:method:: train(json_path, train_nr = 0, *args, **kwargs) Train the underlying transformers NER model. All the extra arguments are passed to the TransformersNER train method. :param json_path: The JSON file path to read the training data from. :type json_path: Union[str, list, None] :param train_nr: The number of the NER object in cat._addl_train to train. Defaults to 0. :type train_nr: int :param \*args: Additional arguments for TransformersNER.train . :param \*\*kwargs: Additional keyword arguments for TransformersNER.train . :Returns: **Tuple[Any, Any, Any]** -- df, examples, dataset .. py:method:: __call__(text, *args, **kwargs) Get the annotated document for text. Undefined arguments and keyword arguments get passed on to the equivalent `CAT` method. :param text: The input text. :type text: Optional[str] :param \*args: Additional arguments for cat.__call__ . :param \*\*kwargs: Additional keyword arguments for cat.__call__ . :Returns: **Optional[Doc]** -- The annotated document. .. py:method:: get_entities(text, *args, **kwargs) Gets the entities recognized within a given text. The output format is identical to `CAT.get_entities`. Undefined arguments and keyword arguments get passed on to CAT.get_entities. :param text: The input text. :type text: str :param \*args: Additional arguments for cat.get_entities . :param \*\*kwargs: Additional keyword arguments for cat.get_entities . :Returns: **dict** -- The output entities. .. py:method:: create(ner) :classmethod: Create a NER model with a TransformersNER :param ner: The TransformersNER instance(s). :type ner: Union[TransformersNER, List[TransformersNER]] :Returns: **NerModel** -- The resulting model .. py:method:: load_model_pack(model_pack_path, config = None) :classmethod: Load NER model from model pack. The method first wraps the loaded CAT instance. :param config: Config for DeId model pack (primarily for stride of overlap window) :param model_pack_path: The model pack path. :type model_pack_path: str :Returns: **NerModel** -- The resulting DeI model.