You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by co...@apache.org on 2012/03/13 17:48:55 UTC
svn commit: r1300236 -
/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/namefind/TokenNameFinderCrossValidatorTest.java
Author: colen
Date: Tue Mar 13 16:48:55 2012
New Revision: 1300236
URL: http://svn.apache.org/viewvc?rev=1300236&view=rev
Log:
OPENNLP-466: Added JUnit that tries to reproduce the issue, but could not reproduce the error.
Modified:
opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/namefind/TokenNameFinderCrossValidatorTest.java
Modified: opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/namefind/TokenNameFinderCrossValidatorTest.java
URL: http://svn.apache.org/viewvc/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/namefind/TokenNameFinderCrossValidatorTest.java?rev=1300236&r1=1300235&r2=1300236&view=diff
==============================================================================
--- opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/namefind/TokenNameFinderCrossValidatorTest.java (original)
+++ opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/namefind/TokenNameFinderCrossValidatorTest.java Tue Mar 13 16:48:55 2012
@@ -17,10 +17,14 @@
package opennlp.tools.namefind;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.*;
+import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
+import java.util.Collections;
+import java.util.Map;
+import opennlp.tools.cmdline.namefind.NameEvaluationErrorListener;
import opennlp.tools.util.ObjectStream;
import opennlp.tools.util.PlainTextByLineStream;
import opennlp.tools.util.TrainingParameters;
@@ -34,6 +38,9 @@ public class TokenNameFinderCrossValidat
private final String TYPE = "default";
@Test
+ /**
+ * Test that reproduces jira OPENNLP-463
+ */
public void testWithNullResources() throws Exception {
FileInputStream sampleDataIn = new FileInputStream(getClass()
@@ -49,8 +56,37 @@ public class TokenNameFinderCrossValidat
TokenNameFinderCrossValidator cv = new TokenNameFinderCrossValidator("en",
TYPE, mlParams, null, null);
- cv.evaluate(sampleStream, 1);
+ cv.evaluate(sampleStream, 2);
assertNotNull(cv.getFMeasure());
}
+
+ @Test
+ /**
+ * Test that tries to reproduce jira OPENNLP-466
+ */
+ public void testWithNameEvaluationErrorListener() throws Exception {
+
+ FileInputStream sampleDataIn = new FileInputStream(getClass()
+ .getClassLoader()
+ .getResource("opennlp/tools/namefind/AnnotatedSentences.txt").getFile());
+ ObjectStream<NameSample> sampleStream = new NameSampleDataStream(
+ new PlainTextByLineStream(sampleDataIn.getChannel(), "ISO-8859-1"));
+
+ TrainingParameters mlParams = ModelUtil.createTrainingParameters(70, 1);
+ mlParams.put(TrainingParameters.ALGORITHM_PARAM,
+ ModelType.MAXENT.toString());
+
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ NameEvaluationErrorListener listener = new NameEvaluationErrorListener(out);
+
+ Map<String, Object> resources = Collections.emptyMap();
+ TokenNameFinderCrossValidator cv = new TokenNameFinderCrossValidator("en",
+ TYPE, mlParams, null, resources, listener);
+
+ cv.evaluate(sampleStream, 2);
+
+ assertTrue(out.size() > 0);
+ assertNotNull(cv.getFMeasure());
+ }
}