We have used the Stanford pipeline in several previous examples. In this example, we will use the Stanford pipeline to extract POS tags. As with our previous Stanford examples, we create a pipeline based on a set of annotators: tokenize, ssplit, and pos.
These will tokenize, split the text into sentences, and then find the POS tags:
Properties props = new Properties(); props.put("annotators", "tokenize, ssplit, pos"); StanfordCoreNLP pipeline = new StanfordCoreNLP(props);
To process the text, we will use the theSentence variable as input to Annotator. The pipeline's annotate method is then invoked, as shown here:
Annotation document = new Annotation(theSentence); pipeline.annotate(document); ...