Skip to content

Commit 6157131

Browse files
J38Stanford NLP
authored andcommitted
add 4class and 7class to end to end test
1 parent 97eb1a0 commit 6157131

File tree

1 file changed

+38
-12
lines changed

1 file changed

+38
-12
lines changed

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

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,33 @@
66

77
import java.util.*;
88

9+
/**
10+
* Test for verifying that NER pipeline results match benchmark output results.
11+
*/
12+
913
public class NERPipelineEndToEndSlowITest extends TestCase {
1014

1115
public static String DATA_PATH = "/u/nlp/data/stanford-corenlp-testing/data/ner";
1216

1317
StanfordCoreNLP pipeline3Class;
18+
StanfordCoreNLP pipeline4Class;
19+
StanfordCoreNLP pipeline7Class;
1420

1521
@Override
1622
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);
2636
}
2737

2838
public List<List<String>> readInExpectedNERLabels(String expectedPath) {
@@ -45,9 +55,7 @@ public List<List<String>> readInExpectedNERLabels(String expectedPath) {
4555
return expectedNERLabels;
4656
}
4757

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) {
5159
List<String> inputSentences = IOUtils.linesFromFile(String.format("%s/%s", DATA_PATH, inputFile));
5260
List<List<String>> expectedLabels = readInExpectedNERLabels(outputFile);
5361
for (int i = 0; i < inputSentences.size() ; i++) {
@@ -56,4 +64,22 @@ public void testEnglish3Class() {
5664
}
5765
}
5866

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+
5985
}

0 commit comments

Comments
 (0)