Skip to Main Content
Natural Language Processing with Java - Second Edition
book

Natural Language Processing with Java - Second Edition

by Richard M. Reese, AshishSingh Bhatia
July 2018
Beginner to intermediate content levelBeginner to intermediate
318 pages
7h 49m
English
Packt Publishing
Content preview from Natural Language Processing with Java - Second Edition

Using the Stanford pipeline to perform tagging

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); ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Natural Language Processing with Java Cookbook

Natural Language Processing with Java Cookbook

Richard M. Reese, Richard M Reese
Natural Language Processing in Action

Natural Language Processing in Action

Cole Howard, Hobson Lane, Hannes Hapke
Natural Language Processing with Python

Natural Language Processing with Python

Steven Bird, Ewan Klein, Edward Loper

Publisher Resources

ISBN: 9781788993494Supplemental Content