Main Content

predict

Predict entities using named entity recognition (NER) model

Since R2023a

    Description

    The predict function detects named entities in text using a hmmEntityModel object.

    To add entity details to documents using a custom NER model, use addDependencyDetails and set the Model option to the custom model.

    tbl = predict(mdl,documents) predicts the named entities of the tokens in the specified documents using the NER model mdl.

    example

    Examples

    collapse all

    Load the trained example hmmEntityModel object.

    load exampleEntityModel
    mdl
    mdl = 
      hmmEntityModel with properties:
    
        Entities: [3×1 categorical]
    
    

    Create a tokenized document object of text data.

    str = "MathWorks develops MATLAB and Simulink.";
    document = tokenizedDocument(str);

    Make predictions using the predict function.

    tbl = predict(mdl,document)
    tbl=6×2 table
           Token           Entity    
        ___________    ______________
    
        "MathWorks"    B-organization
        "develops"     non-entity    
        "MATLAB"       B-product     
        "and"          non-entity    
        "Simulink"     B-product     
        "."            non-entity    
    
    

    Input Arguments

    collapse all

    Custom NER model, specified as a hmmEntityModel object. To train a custom NER model, use the trainHMMEntityModel function.

    For an example, see Train Custom Named Entity Recognition Model.

    Input documents, specified as a tokenizedDocument array.

    Output Arguments

    collapse all

    Predicted entities, returned as a table with these variables:

    Algorithms

    collapse all

    Alternative Functionality

    To add entity details to documents using a custom NER model, use addDependencyDetails and set the Model option to the custom model.

    Version History

    Introduced in R2023a