77 */
88package org .cogcomp .md ;
99
10- import edu .illinois .cs .cogcomp .pos .POSAnnotator ;
11- import org .cogcomp .md .LbjGen .*;
12-
1310import edu .illinois .cs .cogcomp .annotation .Annotator ;
1411import edu .illinois .cs .cogcomp .annotation .AnnotatorException ;
1512import edu .illinois .cs .cogcomp .core .datastructures .Pair ;
2623import edu .illinois .cs .cogcomp .ner .ExpressiveFeatures .FlatGazetteers ;
2724import edu .illinois .cs .cogcomp .ner .ExpressiveFeatures .GazetteersFactory ;
2825import org .cogcomp .Datastore ;
26+ import org .cogcomp .md .LbjGen .bio_classifier_nam ;
27+ import org .cogcomp .md .LbjGen .bio_classifier_nom ;
28+ import org .cogcomp .md .LbjGen .bio_classifier_pro ;
29+ import org .cogcomp .md .LbjGen .extent_classifier ;
2930
3031import java .io .File ;
3132import java .util .Vector ;
4041 */
4142public class MentionAnnotator extends Annotator {
4243
43- private bio_classifier_nam classifier_nam ;
44- private bio_classifier_nom classifier_nom ;
45- private bio_classifier_pro classifier_pro ;
44+ private bio_classifier_nam classifier_nam = null ;
45+ private bio_classifier_nom classifier_nom = null ;
46+ private bio_classifier_pro classifier_pro = null ;
47+ String fileName_NAM = "" ;
48+ String fileName_NOM = "" ;
49+ String fileName_PRO = "" ;
50+ String fileName_EXTENT = "" ;
4651 private extent_classifier classifier_extent ;
4752 private Learner [] candidates ;
4853 private FlatGazetteers gazetteers ;
@@ -74,16 +79,34 @@ public MentionAnnotator(boolean lazilyInitialize, String mode){
7479 _mode = mode ;
7580 }
7681
82+ /**
83+ *
84+ * @param nam_model_path NAM model file path (excluding the extension)
85+ * @param nom_model_path NOM model file path (excluding the extension)
86+ * @param pro_model_path PRO model file path (excluding the extension)
87+ * @param extent_model_path EXTENT model file path (excluding the extension)
88+ * @param mode Useless in this case
89+ */
90+ public MentionAnnotator (String nam_model_path , String nom_model_path , String pro_model_path , String extent_model_path , String mode ){
91+ super (ViewNames .MENTION , new String []{ViewNames .POS }, true );
92+ _mode = mode ;
93+ if (fileName_NAM != null ) {
94+ fileName_NAM = nam_model_path ;
95+ }
96+ if (fileName_NOM != null ) {
97+ fileName_NOM = nom_model_path ;
98+ }
99+ if (fileName_PRO != null ) {
100+ fileName_PRO = pro_model_path ;
101+ }
102+ }
103+
77104 public void initialize (ResourceManager rm ){
78- String fileName_NAM = "" ;
79- String fileName_NOM = "" ;
80- String fileName_PRO = "" ;
81- String fileName_EXTENT = "" ;
82105 try {
83106 Datastore ds = new Datastore (new ResourceConfigurator ().getDefaultConfig ());
84107 if (_mode .contains ("ACE" )) {
85- File extentFlie = ds .getDirectory ("org.cogcomp.mention" , "ACE_EXTENT" , 1.0 , false );
86- fileName_EXTENT = extentFlie .getPath () + File .separator + "ACE_EXTENT" + File .separator + "EXTENT_ACE" ;
108+ File extentFile = ds .getDirectory ("org.cogcomp.mention" , "ACE_EXTENT" , 1.0 , false );
109+ fileName_EXTENT = extentFile .getPath () + File .separator + "ACE_EXTENT" + File .separator + "EXTENT_ACE" ;
87110 if (_mode .contains ("NON" )){
88111 File headFile = ds .getDirectory ("org.cogcomp.mention" , "ACE_HEAD_NONTYPE" , 1.0 , false );
89112 fileName_NAM = headFile .getPath () + File .separator + "ACE_HEAD_NONTYPE" + File .separator + "ACE_NAM" ;
@@ -98,8 +121,8 @@ public void initialize(ResourceManager rm){
98121 }
99122 }
100123 else if (_mode .contains ("ERE" )){
101- File extentFlie = ds .getDirectory ("org.cogcomp.mention" , "ERE_EXTENT" , 1.0 , false );
102- fileName_EXTENT = extentFlie .getPath () + File .separator + "ERE_EXTENT" + File .separator + "EXTENT_ERE" ;
124+ File extentFile = ds .getDirectory ("org.cogcomp.mention" , "ERE_EXTENT" , 1.0 , false );
125+ fileName_EXTENT = extentFile .getPath () + File .separator + "ERE_EXTENT" + File .separator + "EXTENT_ERE" ;
103126 if (_mode .contains ("NON" )){
104127 File headFile = ds .getDirectory ("org.cogcomp.mention" , "ERE_HEAD_NONTYPE" , 1.0 , false );
105128 fileName_NAM = headFile .getPath () + File .separator + "ERE_HEAD_NONTYPE" + File .separator + "ERE_NAM" ;
@@ -117,11 +140,29 @@ else if (_mode.contains("ERE")){
117140 catch (Exception e ){
118141 e .printStackTrace ();
119142 }
120-
121- classifier_nam = new bio_classifier_nam (fileName_NAM + ".lc" , fileName_NAM + ".lex" );
122- classifier_nom = new bio_classifier_nom (fileName_NOM +".lc" , fileName_NOM + ".lex" );
123- classifier_pro = new bio_classifier_pro (fileName_PRO + ".lc" , fileName_PRO + ".lex" );
124- classifier_extent = new extent_classifier (fileName_EXTENT + ".lc" , fileName_EXTENT + ".lex" );
143+ if (!fileName_NAM .equals ("" )) {
144+ classifier_nam = new bio_classifier_nam (fileName_NAM + ".lc" , fileName_NAM + ".lex" );
145+ }
146+ if (!fileName_NOM .equals ("" )) {
147+ classifier_nom = new bio_classifier_nom (fileName_NOM + ".lc" , fileName_NOM + ".lex" );
148+ }
149+ if (!fileName_PRO .equals ("" )) {
150+ classifier_pro = new bio_classifier_pro (fileName_PRO + ".lc" , fileName_PRO + ".lex" );
151+ }
152+ if (!fileName_EXTENT .equals ("" )) {
153+ classifier_extent = new extent_classifier (fileName_EXTENT + ".lc" , fileName_EXTENT + ".lex" );
154+ }
155+ else {
156+ try {
157+ Datastore ds = new Datastore (new ResourceConfigurator ().getDefaultConfig ());
158+ File extentFile = ds .getDirectory ("org.cogcomp.mention" , "ACE_EXTENT" , 1.0 , false );
159+ fileName_EXTENT = extentFile .getPath () + File .separator + "ACE_EXTENT" + File .separator + "EXTENT_ACE" ;
160+ classifier_extent = new extent_classifier (fileName_EXTENT + ".lc" , fileName_EXTENT + ".lex" );
161+ }
162+ catch (Exception e ){
163+ e .printStackTrace ();
164+ }
165+ }
125166
126167 try {
127168 Datastore ds = new Datastore (new ResourceConfigurator ().getDefaultConfig ());
0 commit comments