You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by jo...@apache.org on 2011/01/12 13:08:37 UTC
svn commit: r1058103 -
/incubator/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/formats/Conll03NameSampleStreamTest.java
Author: joern
Date: Wed Jan 12 12:08:37 2011
New Revision: 1058103
URL: http://svn.apache.org/viewvc?rev=1058103&view=rev
Log:
OpenNLP-15 Added test cases
Modified:
incubator/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/formats/Conll03NameSampleStreamTest.java
Modified: incubator/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/formats/Conll03NameSampleStreamTest.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/formats/Conll03NameSampleStreamTest.java?rev=1058103&r1=1058102&r2=1058103&view=diff
==============================================================================
--- incubator/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/formats/Conll03NameSampleStreamTest.java (original)
+++ incubator/opennlp/trunk/opennlp-tools/src/test/java/opennlp/tools/formats/Conll03NameSampleStreamTest.java Wed Jan 12 12:08:37 2011
@@ -34,6 +34,10 @@ import org.junit.Test;
*/
public class Conll03NameSampleStreamTest {
+ private static final String ENGLISH_SAMPLE = "conll2003-en.sample";
+ private static final String GERMAN_SAMPLE = "conll2003-de.sample";
+
+
private static ObjectStream<NameSample> openData(LANGUAGE lang, String name) throws IOException {
InputStream in = Conll03NameSampleStreamTest.class.getResourceAsStream("/opennlp/tools/formats/" + name);
@@ -43,10 +47,9 @@ public class Conll03NameSampleStreamTest
@Test
public void testParsingEnglishSample() throws IOException {
- ObjectStream<NameSample> sampleStream = openData(LANGUAGE.EN, "conll2003-en.sample");
+ ObjectStream<NameSample> sampleStream = openData(LANGUAGE.EN, ENGLISH_SAMPLE);
NameSample personName = sampleStream.read();
-
assertNotNull(personName);
assertEquals(9, personName.getSentence().length);
@@ -67,5 +70,29 @@ public class Conll03NameSampleStreamTest
assertNull(sampleStream.read());
}
+
+ @Test(expected=IOException.class)
+ public void testParsingEnglishSampleWithGermanAsLanguage() throws IOException {
+ ObjectStream<NameSample> sampleStream = openData(LANGUAGE.DE, ENGLISH_SAMPLE);
+ sampleStream.read();
+ }
+
+ @Test(expected=IOException.class)
+ public void testParsingGermanSampleWithEnglishAsLanguage() throws IOException {
+ ObjectStream<NameSample> sampleStream = openData(LANGUAGE.EN, GERMAN_SAMPLE);
+ sampleStream.read();
+ }
+
+ @Test
+ public void testParsingGermanSample() throws IOException {
+ ObjectStream<NameSample> sampleStream = openData(LANGUAGE.DE, GERMAN_SAMPLE);
+
+ NameSample personName = sampleStream.read();
+ assertNotNull(personName);
+
+ assertEquals(5, personName.getSentence().length);
+ assertEquals(0, personName.getNames().length);
+ assertEquals(true, personName.isClearAdaptiveDataSet());
+ }
}
\ No newline at end of file