Skip to content

Commit 378e02e

Browse files
committed
Simple test of the reading code when there's no enhanced graph - clearly was needed, considering the previous bug
1 parent 91cb8e0 commit 378e02e

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# sent_id = weblog-blogspot.com_healingiraq_20040409053012_ENG_20040409_053012-0022
2+
# text = Over 300 Iraqis are reported dead and 500 wounded in Fallujah alone.
3+
1 Over over ADV RB _ 2 advmod _ SpacesBefore=\s\s
4+
2 300 300 NUM CD NumForm=Digit|NumType=Card 3 nummod _ _
5+
3 Iraqis Iraqi PROPN NNPS Number=Plur 5 nsubj:pass _ _
6+
4 are be AUX VBP Mood=Ind|Number=Plur|Person=3|Tense=Pres|VerbForm=Fin 5 aux:pass _ _
7+
5 reported report VERB VBN Tense=Past|VerbForm=Part|Voice=Pass 0 root _ _
8+
6 dead dead ADJ JJ Degree=Pos 5 xcomp _ _
9+
7 and and CCONJ CC _ 8 cc _ _
10+
8 500 500 NUM CD NumForm=Digit|NumType=Card 5 conj _ _
11+
9 wounded wounded ADJ JJ Degree=Pos 8 orphan _ _
12+
10 in in ADP IN _ 11 case _ _
13+
11 Fallujah Fallujah PROPN NNP Number=Sing 5 obl _ _
14+
12 alone alone ADV RB _ 11 advmod _ SpaceAfter=No
15+
13 . . PUNCT . _ 5 punct _ _
16+

itest/src/edu/stanford/nlp/pipeline/CoNLLUReaderITest.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,4 +423,31 @@ public void testReadingInEmpties() throws ClassNotFoundException, IOException {
423423
assertEquals(" ", tokens.get(0).before());
424424
}
425425

426+
427+
public static final String noEnhancedPath = String.format("edu/stanford/nlp/pipeline/en-example-noenhanced.conllu");
428+
429+
@Test
430+
/**
431+
* Here we run fewer tests. Just make sure the EmptyToken is properly handled,
432+
* and make sure there isn't some weird line skipping going on with the rest of the tokens
433+
*/
434+
public void testReadingNoEnhanced() throws ClassNotFoundException, IOException {
435+
Annotation readInDocument = new CoNLLUReader(new Properties()).readCoNLLUFile(noEnhancedPath).get(0);
436+
437+
// this document only has one sentence
438+
List<CoreMap> sentences = readInDocument.get(CoreAnnotations.SentencesAnnotation.class);
439+
assertEquals(1, sentences.size());
440+
441+
CoreMap sentence = sentences.get(0);
442+
443+
// cursory check of the tokens
444+
List<CoreLabel> tokens = sentence.get(CoreAnnotations.TokensAnnotation.class);
445+
assertEquals(13, tokens.size());
446+
assertEquals(13, EXPECTED_ENGLISH_WORDS.length);
447+
for (int i = 0; i < tokens.size(); ++i) {
448+
assertEquals(i+1, tokens.get(i).index());
449+
assertEquals(EXPECTED_ENGLISH_WORDS[i], tokens.get(i).value());
450+
}
451+
}
452+
426453
}

0 commit comments

Comments
 (0)