uima-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From twgo...@apache.org
Subject svn commit: r701191 - /incubator/uima/sandbox/trunk/Tagger/src/test/java/org/apache/uima/examples/tagger/test/TaggerTest.java
Date Thu, 02 Oct 2008 17:11:07 GMT
Author: twgoetz
Date: Thu Oct  2 10:11:06 2008
New Revision: 701191

URL: http://svn.apache.org/viewvc?rev=701191&view=rev
Log:
Jira UIMA-1193: protect against NPE.  Add test case processing Moby Dick to guard against
regression.

https://issues.apache.org/jira/browse/UIMA-1193

Modified:
    incubator/uima/sandbox/trunk/Tagger/src/test/java/org/apache/uima/examples/tagger/test/TaggerTest.java

Modified: incubator/uima/sandbox/trunk/Tagger/src/test/java/org/apache/uima/examples/tagger/test/TaggerTest.java
URL: http://svn.apache.org/viewvc/incubator/uima/sandbox/trunk/Tagger/src/test/java/org/apache/uima/examples/tagger/test/TaggerTest.java?rev=701191&r1=701190&r2=701191&view=diff
==============================================================================
--- incubator/uima/sandbox/trunk/Tagger/src/test/java/org/apache/uima/examples/tagger/test/TaggerTest.java
(original)
+++ incubator/uima/sandbox/trunk/Tagger/src/test/java/org/apache/uima/examples/tagger/test/TaggerTest.java
Thu Oct  2 10:11:06 2008
@@ -30,6 +30,7 @@
 import java.io.OutputStreamWriter;
 import java.io.UnsupportedEncodingException;
 import java.io.Writer;
+import java.net.URL;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collections;
@@ -48,6 +49,7 @@
 import org.apache.uima.examples.tagger.HMMTagger;
 import org.apache.uima.examples.tagger.Viterbi;
 import org.apache.uima.jcas.JCas;
+import org.apache.uima.test.junit_extension.JUnitExtension;
 import org.apache.uima.util.FileUtils;
 import org.apache.uima.util.XMLInputSource;
 import org.apache.uima.util.XMLParser;
@@ -210,7 +212,12 @@
   }
 
   /**
-   * Run tagger on Moby Dick and compare result to pre-computed XCAS.
+   * Run tagger on Moby Dick and compare result to pre-computed XCAS. This test case is a
bit
+   * brittle. First of all, it requires the uimaj-core project as a neighbor, otherwise it
won't
+   * find moby.txt, the test input.  Secondly, the reference output is only a list of POS
tags.
+   * This is so the file doesn't get so big.  Finally, if anything changes, even improvements,
this
+   * test will most likely fail and will need to be updated.  There's an unused method below
that
+   * can be used to write a new set of POS tags when the old ones become obsolete.
    */
   public void testMobyDick() {
     try {
@@ -218,8 +225,16 @@
       XMLInputSource xmlInputSource = new XMLInputSource("desc/HmmTaggerAggregate.xml");
       AnalysisEngine taggerEngine = UIMAFramework.produceAnalysisEngine(xmlParser
           .parseResourceSpecifier(xmlInputSource));
-      String text = FileUtils.file2String(
-          new File("../uimaj-core/src/test/resources/data/moby.txt"), "utf-8");
+      String text = null;
+      try {
+        text = FileUtils.file2String(new File("../uimaj-core/src/test/resources/data/moby.txt"),
+            "utf-8");
+      } catch (FileNotFoundException e) {
+        System.err
+            .println("Warning: this test case runs only if uimaj-core is a sister project
to the tagger project; otherwise, the test input data is not available.");
+        System.err.println("Skipping test");
+        return;
+      }
       JCas cas = taggerEngine.newJCas();
       cas.setDocumentText(text);
       taggerEngine.process(cas);
@@ -245,7 +260,7 @@
     }
     return tags;
   }
-  
+
   private List<String> getCurrentTagList(JCas cas) {
     List<String> tagList = new ArrayList<String>();
     AnnotationIndex tokenIndex = cas.getAnnotationIndex(TokenAnnotation.type);



Mime
View raw message