langtest.modelhandler.spacy_modelhandler.PretrainedModelForNER#

class PretrainedModelForNER(model)#

Bases: ModelAPI

SpaCy pretrained model for NER tasks

Parameters:

model – Pretrained SpaCy pipeline.

__init__(model)#

Constructor method

Parameters:

model – spacy model

Methods

__init__(model)

Constructor method

load_model(path)

Load and return SpaCy pipeline

predict(text, *args, **kwargs)

Perform predictions on the input text.

predict_raw(text)

Predict a list of labels in form of strings.

Attributes

model_registry

classmethod load_model(path: str)#

Load and return SpaCy pipeline

Parameters:

path (str) – name of path to model to load

predict(text: str, *args, **kwargs) NEROutput#

Perform predictions on the input text.

Parameters:
  • text (str) – Input text to perform NER on.

  • kwargs – Additional keyword arguments.

Keyword Arguments:

group_entities (bool) – Option to group entities.

Returns:

A list of named entities recognized in the input text.

Return type:

NEROutput

predict_raw(text: str) List[str]#

Predict a list of labels in form of strings.

Parameters:

text (str) – Input text to perform NER on.

Returns:

A list of named entities recognized in the input text.

Return type:

List[str]