Java
// import nlp4j.Document;
// import nlp4j.Keyword;
// import nlp4j.impl.DefaultDocument;
// import nlp4j.stanford.StanfordPosAnnotator;
Document doc = new DefaultDocument();
doc.putAttribute("text", "I eat sushi with chopsticks.");
StanfordPosAnnotator ann = new StanfordPosAnnotator();
ann.setProperty("target", "text");
ann.annotate(doc); // do annotation
for (Keyword kwd : doc.getKeywords()) {
System.err.println(kwd);
}
Result
I [facet=word.PRP, str=I]
eat [facet=word.VBP, str=eat]
sushi [facet=word.NN, str=sushi]
with [facet=word.IN, str=with]
chopstick [facet=word.NNS, str=chopsticks]
. [facet=word.., str=.]