@@ -74,22 +74,34 @@ public static void main(String[] args) throws IOException, ClassNotFoundExceptio
74
74
RedwoodConfiguration .standard ().apply (); // Disable SLF4J crap.
75
75
ArgumentParser .fillOptions (KBPEnsembleExtractor .class , args );
76
76
77
- Object object = IOUtils .readObjectFromURLOrClasspathOrFileSystem (STATISTICAL_MODEL );
78
77
KBPRelationExtractor statisticalExtractor ;
79
- if (object instanceof LinearClassifier ) {
80
- //noinspection unchecked
81
- statisticalExtractor = new KBPStatisticalExtractor ((Classifier <String , String >) object );
82
- } else if (object instanceof KBPStatisticalExtractor ) {
83
- statisticalExtractor = (KBPStatisticalExtractor ) object ;
78
+ if (STATISTICAL_MODEL .length () == 0 ) {
79
+ logger .info ("No statistical model will be used." );
80
+ statisticalExtractor = null ;
84
81
} else {
85
- throw new ClassCastException (object .getClass () + " cannot be cast into a " + KBPStatisticalExtractor .class );
82
+ Object object = IOUtils .readObjectFromURLOrClasspathOrFileSystem (STATISTICAL_MODEL );
83
+ if (object instanceof LinearClassifier ) {
84
+ //noinspection unchecked
85
+ statisticalExtractor = new KBPStatisticalExtractor ((Classifier <String , String >) object );
86
+ } else if (object instanceof KBPStatisticalExtractor ) {
87
+ statisticalExtractor = (KBPStatisticalExtractor ) object ;
88
+ } else {
89
+ throw new ClassCastException (object .getClass () + " cannot be cast into a " + KBPStatisticalExtractor .class );
90
+ }
91
+ logger .info ("Read statistical model from " + STATISTICAL_MODEL );
92
+ }
93
+
94
+ KBPRelationExtractor extractor ;
95
+ if (statisticalExtractor == null ) {
96
+ extractor = new KBPEnsembleExtractor (
97
+ new KBPTokensregexExtractor (TOKENSREGEX_DIR ),
98
+ new KBPSemgrexExtractor (SEMGREX_DIR ));
99
+ } else {
100
+ extractor = new KBPEnsembleExtractor (
101
+ new KBPTokensregexExtractor (TOKENSREGEX_DIR ),
102
+ new KBPSemgrexExtractor (SEMGREX_DIR ),
103
+ statisticalExtractor );
86
104
}
87
- logger .info ("Read statistical model from " + STATISTICAL_MODEL );
88
- KBPRelationExtractor extractor = new KBPEnsembleExtractor (
89
- new KBPTokensregexExtractor (TOKENSREGEX_DIR ),
90
- new KBPSemgrexExtractor (SEMGREX_DIR ),
91
- statisticalExtractor
92
- );
93
105
94
106
List <Pair <KBPInput , String >> testExamples = KBPRelationExtractor .readDataset (TEST_FILE );
95
107
0 commit comments