6
6
7
7
import java .util .*;
8
8
9
+ /**
10
+ * Test for verifying that NER pipeline results match benchmark output results.
11
+ */
12
+
9
13
public class NERPipelineEndToEndSlowITest extends TestCase {
10
14
11
15
public static String DATA_PATH = "/u/nlp/data/stanford-corenlp-testing/data/ner" ;
12
16
13
17
StanfordCoreNLP pipeline3Class ;
18
+ StanfordCoreNLP pipeline4Class ;
19
+ StanfordCoreNLP pipeline7Class ;
14
20
15
21
@ Override
16
22
public void setUp () {
17
- // set up the pipeline with NER tokenization
18
- Properties props3Class = new Properties ();
19
- props3Class .setProperty ("annotators" , "tokenize,ssplit,pos,lemma,ner" );
20
- props3Class .setProperty ("ssplit.eolonly" , "true" );
21
- props3Class .setProperty ("ner.model" , "edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz" );
22
- props3Class .setProperty ("ner.applyNumericClassifiers" , "false" );
23
- props3Class .setProperty ("ner.applyFineGrained" , "false" );
24
- props3Class .setProperty ("ner.useSUTime" , "false" );
25
- pipeline3Class = new StanfordCoreNLP (props3Class );
23
+ // set up the pipeline using 3-class model
24
+ Properties props = new Properties ();
25
+ props .setProperty ("annotators" , "tokenize,ssplit,pos,lemma,ner" );
26
+ props .setProperty ("ssplit.eolonly" , "true" );
27
+ props .setProperty ("ner.model" , "edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz" );
28
+ props .setProperty ("ner.statisticalOnly" , "true" );
29
+ pipeline3Class = new StanfordCoreNLP (props );
30
+ // set up the pipeline using 4-class model
31
+ props .setProperty ("ner.model" , "edu/stanford/nlp/models/ner/english.conll.4class.distsim.crf.ser.gz" );
32
+ pipeline4Class = new StanfordCoreNLP (props );
33
+ // set up thet pipeline using 7-class model
34
+ props .setProperty ("ner.model" , "edu/stanford/nlp/models/ner/english.muc.7class.distsim.crf.ser.gz" );
35
+ pipeline7Class = new StanfordCoreNLP (props );
26
36
}
27
37
28
38
public List <List <String >> readInExpectedNERLabels (String expectedPath ) {
@@ -45,9 +55,7 @@ public List<List<String>> readInExpectedNERLabels(String expectedPath) {
45
55
return expectedNERLabels ;
46
56
}
47
57
48
- public void testEnglish3Class () {
49
- String inputFile = "english.all.3class.distsim-regression.input" ;
50
- String outputFile = "english.all.3class.distsim-regression.expected" ;
58
+ public void runModelTest (String inputFile , String outputFile ) {
51
59
List <String > inputSentences = IOUtils .linesFromFile (String .format ("%s/%s" , DATA_PATH , inputFile ));
52
60
List <List <String >> expectedLabels = readInExpectedNERLabels (outputFile );
53
61
for (int i = 0 ; i < inputSentences .size () ; i ++) {
@@ -56,4 +64,22 @@ public void testEnglish3Class() {
56
64
}
57
65
}
58
66
67
+ public void testEnglish3Class () {
68
+ String threeClassInput = "english.all.3class.distsim-regression.input" ;
69
+ String threeClassOutput = "english.all.3class.distsim-regression.expected" ;
70
+ runModelTest (threeClassInput , threeClassOutput );
71
+ }
72
+
73
+ public void testEnglish4Class () {
74
+ String fourClassInput = "english.conll.4class.distsim-regression.input" ;
75
+ String fourClassOutput = "english.conll.4class.distsim-regression.expected" ;
76
+ runModelTest (fourClassInput , fourClassOutput );
77
+ }
78
+
79
+ public void testEnglish7Class () {
80
+ String sevenClassInput = "english.muc.7class.distsim-regression.input" ;
81
+ String sevenClassOutput = "english.muc.7class.distsim-regression.expected" ;
82
+ runModelTest (sevenClassInput , sevenClassOutput );
83
+ }
84
+
59
85
}
0 commit comments