Skip to content

Commit

Permalink
Updates to bring Chapter 2 code in-line with manuscript
Browse files Browse the repository at this point in the history
  • Loading branch information
drewfarris committed Feb 5, 2012
1 parent e78e2fb commit 85f2e47
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/test/java/com/tamingtext/opennlp/POSTaggerTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

import opennlp.tools.postag.POSModel;
import opennlp.tools.postag.POSTaggerME;
import opennlp.tools.tokenize.WhitespaceTokenizer;
import opennlp.tools.tokenize.SimpleTokenizer;

import org.junit.Test;

Expand All @@ -46,11 +46,12 @@ public void test() throws IOException {
POSModel model = new POSModel(posModelStream);

POSTaggerME tagger = new POSTaggerME(model);
String[] words = WhitespaceTokenizer.INSTANCE.tokenize("The quick, red fox jumped over the lazy, brown dogs");//<co id="opennlpPOS.co.tokenize"/>
String[] words = SimpleTokenizer.INSTANCE.tokenize("The quick, red fox jumped over the lazy, brown dogs.");//<co id="opennlpPOS.co.tokenize"/>
String[] result = tagger.tag(words);//<co id="opennlpPOS.co.tag"/>
for (int i=0 ; i < words.length; i++) {
System.err.println(words[i] + "\t" + result[i]);
System.err.print(words[i] + "/" + result[i] + " ");
}
System.err.println("\n");
/*
<calloutlist>
<callout arearefs="opennlpPOS.co.tagger"><para>Give the path to the POS Model</para></callout>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ public void testOpenNLP() throws Exception {
InputStream modelStream = new FileInputStream(modelFile);
SentenceModel model = new SentenceModel(modelStream);
SentenceDetector detector = new SentenceDetectorME(model);//<co id="openSentDetect.co.detect"/>
;//<co id="openSentDetect.co.detect"/>
String testString = "This is a sentence. It has fruits, vegetables," +
" etc. but does not have meat. Mr. Smith went to Washington.";
String[] result = detector.sentDetect(testString);//<co id="openSentDetect.co.run"/>
Expand Down

0 comments on commit 85f2e47

Please sign in to comment.