In this recipe, we will use the OpenNLP API to identify POS. Specifically, we will use the POSTaggerME class to tag the words of a sentence. The process of tagging is the association of a POS tag to a word of a sentence. The POSTaggerME class uses a maximum entropy model. This type of model was discussed in the Tokenization using maximum entropy recipe of Chapter 1, Preparing Text for Analysis and Tokenization.
Finding POS using tagging
Getting ready
To prepare, we need to do the following:
- Create a new Maven project.
- Add the following dependency to the project's POM file:
<dependency>
<groupId>org.apache.opennlp</groupId>
<artifactId>opennlp-tools</artifactId>
<version>1...