Named Entity Extraction Example in openNLP using Java

Named Entity Extraction Example in openNLP

Named Entity Extraction Example in openNLP – In this openNLP tutorial, we shall try entity extraction from a sentence using openNLP pre-built models, that were already trained to find the named entity.

What is Named Entity Recognition/Extraction (NER)?

Named Entity Recognition is a task of finding the named entities that could possibly belong to categories like persons, organizations, dates, percentages, etc., and categorize the identified entity to one of these categories.

How Named Entity Extraction is done in openNLP ?

In openNLP, Named Entity Extraction is done using statistical models, i.e., machine learning techniques. Coming to specifics, Maxent modeling is used. To get an intuition on how Maxent modeling works, refer to the motivating example of Maxent modeling.

Example: Named Entity Extraction Example in openNLP

The following example, NameFinderExample.java shows how to use NameFinderME class to extract named entities, person and place.

When the example program, NameFinderExample.java is run, the output to console is:

The project structure and the model file location, etc., is shown below:

Named Entity Extraction Example in openNLP using Java - example project structure

Example Project – Structure

Model File:

The model files en-ner-person.bin, en-ner-person.bin and other ner models are available at http://opennlp.sourceforge.net/models-1.5/. Stay updated regarding latest releases of openNLP or model files, at https://opennlp.apache.org/download.html

 

Conclusion :

In this openNLP tutorial, we have seen how to use Named Entity Extraction API of openNLP to extract named entities from a paragraph or sentence.