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 16:25:17 UTC

svn commit: r1300185 - /opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/namefind/TokenNameFinderCrossValidatorTest.java

Author: colen
Date: Tue Mar 13 15:25:16 2012
New Revision: 1300185

URL: http://svn.apache.org/viewvc?rev=1300185&view=rev
Log:
OPENNLP-463: Added JUnit test.

Added:
    opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/namefind/TokenNameFinderCrossValidatorTest.java   (with props)

Added: 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=1300185&view=auto
==============================================================================
--- opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/namefind/TokenNameFinderCrossValidatorTest.java (added)
+++ opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/namefind/TokenNameFinderCrossValidatorTest.java Tue Mar 13 15:25:16 2012
@@ -0,0 +1,56 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package opennlp.tools.namefind;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.FileInputStream;
+
+import opennlp.tools.util.ObjectStream;
+import opennlp.tools.util.PlainTextByLineStream;
+import opennlp.tools.util.TrainingParameters;
+import opennlp.tools.util.model.ModelType;
+import opennlp.tools.util.model.ModelUtil;
+
+import org.junit.Test;
+
+public class TokenNameFinderCrossValidatorTest {
+
+  private final String TYPE = "default";
+
+  @Test
+  public void testWithNullResources() 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());
+
+    TokenNameFinderCrossValidator cv = new TokenNameFinderCrossValidator("en",
+        TYPE, mlParams, null, null);
+
+    cv.evaluate(sampleStream, 1);
+
+    assertNotNull(cv.getFMeasure());
+  }
+}

Propchange: opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/namefind/TokenNameFinderCrossValidatorTest.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain