@@ -0,0 +1,1828 @@
+package org.qifu.common.test;%0A%0Aimport java.io.File;%0Aimport java.io.FileInputStream;%0Aimport java.io.InputStream;%0A%0Aimport opennlp.tools.chunker.ChunkerME;%0Aimport opennlp.tools.chunker.ChunkerModel;%0Aimport opennlp.tools.postag.POSModel;%0Aimport opennlp.tools.postag.POSTaggerME;%0Aimport opennlp.tools.tokenize.TokenizerME;%0Aimport opennlp.tools.tokenize.TokenizerModel;%0Aimport opennlp.tools.util.Span;%0A%0Apublic class OpenNLPNounPhraseExtractor %7B%0A%09%0A%09public static void main(String args%5B%5D) throws Exception %7B%0A%09%09%0A%09%09TokenizerModel tm = new TokenizerModel(new FileInputStream(new File(%22/home/test/TestNLP/en-token.bin%22)));%0A%09%09TokenizerME wordBreaker = new TokenizerME(tm);%0A%09%09POSModel pm = new POSModel(new FileInputStream(new File(%22/home/test/TestNLP/en-pos-maxent.bin%22)));%0A%09%09POSTaggerME posme = new POSTaggerME(pm);%0A%09%09InputStream modelIn = new FileInputStream(%22/home/test/TestNLP/en-chunker.bin%22);%0A%09%09ChunkerModel chunkerModel = new ChunkerModel(modelIn);%0A%09%09ChunkerME chunkerME = new ChunkerME(chunkerModel);%0A%09%09//this is your sentence%0A%09%09String sentence = %22Barack Hussein Obama II  is the 44th President of the United States, and the first African American to hold the office.%22;%0A%09%09//words is the tokenized sentence%0A%09%09String%5B%5D words = wordBreaker.tokenize(sentence);%0A%09%09//posTags are the parts of speech of every word in the sentence (The chunker needs this info of course)%0A%09%09String%5B%5D posTags = posme.tag(words);%0A%09%09//chunks are the start end %22spans%22 indices to the chunks in the words array%0A%09%09Span%5B%5D chunks = chunkerME.chunkAsSpans(words, posTags);%0A%09%09//chunkStrings are the actual chunks%0A%09%09String%5B%5D chunkStrings = Span.spansToStrings(chunks, words);%0A%09%09for (int i = 0; i %3C chunks.length; i++) %7B%0A%09%09%09String np = chunkStrings%5Bi%5D;%0A%09%09%09System.out.println(np);%0A%09%09%09if (np.indexOf(%22Obama%22) %3E -1) %7B%0A%09%09%09%09System.out.println(%22* %5B%22+np+%22%5D%22);%0A%09%09%09%7D%0A%09%09%7D%09%0A%09%09%0A%09%7D%0A%0A%7D

update add test code.