-
Notifications
You must be signed in to change notification settings - Fork 18
English POS tagger for Java
aburkov edited this page Jun 27, 2015
·
1 revision
With xpresso you can easily POS tag any English text with the very fast and accurate (~97%) Stanford CoreNLP english-left3words model.
import com.wantedtech.common.xpresso.sentence.Sentence;
import com.wantedtech.common.xpresso.sentence.PosTagger;
import com.wantedtech.common.xpresso.sentence.pos.en.stanford.MaxentPosTagger;
PosTagger posTagger = new MaxentPosTagger();
String text = "Some English text. Multiple sentences.";
for (Sentence sent : x.String.EN.tokenize(text)) {
posTagger.tag(sent);
x.print(sent.getAnnotations("pos"));
}
Console: [(Some, DT), (English, NNP), (text, NN), (., .)]
[(Multiple, JJ), (sentences, NNS), (., .)]