use of edu.illinois.cs.cogcomp.ner.config.NerOntonotesConfigurator in project cogcomp-nlp by CogComp.
the class Parameters method readConfigAndLoadExternalData.
/**
* This just calls {@link #readAndLoadConfig readAndLoadConfig}. The main difference is that it
* assigns the result to {@link ParametersForLbjCode#currentParameters}. This is important:
* <code>ParametersForLbjCode</code> is changed because of this.
*
* @param configFile the path to a config file, to be loaded by a <code>ResourceManager</code>.
* @param areWeTraining this value determines whether or not this run will involve training a
* model. If we are training, then we make sure there exists a folder in which to put the
* trained model. If not, then we make sure the model exists.
* @throws IOException if the <code>ResourceManager</code> doesn't load correctly.
*/
public static void readConfigAndLoadExternalData(String configFile, boolean areWeTraining) throws IOException {
ResourceManager rm = new ResourceManager(configFile);
String modelName = rm.getString("modelName");
String modelDir = rm.getString("pathToModelFile");
Map<String, String> nonDefaultProps = new HashMap<>();
nonDefaultProps.put(NerBaseConfigurator.PATH_TO_MODEL, modelDir);
NerBaseConfigurator baseConfigurator = new NerBaseConfigurator();
NerOntonotesConfigurator ontonotesConfigurator = new NerOntonotesConfigurator();
// settings
switch(modelName) {
case ViewNames.NER_CONLL:
ParametersForLbjCode.currentParameters = readAndLoadConfig(baseConfigurator.getConfig(nonDefaultProps), areWeTraining);
break;
case ViewNames.NER_ONTONOTES:
ParametersForLbjCode.currentParameters = readAndLoadConfig(baseConfigurator.getConfig(ontonotesConfigurator.getConfig(nonDefaultProps)), areWeTraining);
break;
default:
ParametersForLbjCode.currentParameters = readAndLoadConfig(baseConfigurator.getConfig(rm), areWeTraining);
break;
}
}
use of edu.illinois.cs.cogcomp.ner.config.NerOntonotesConfigurator in project cogcomp-nlp by CogComp.
the class NERAnnotator method initialize.
/**
* Superclass calls this method either on instantiation or at first call to getView(). Logging
* has been disabled because non-static logger is not initialized at the time this is called if
* non-lazy initialization is specified.
*
* @param nerRm configuration parameters passed to constructor
*/
@Override
public void initialize(ResourceManager nerRm) {
if (ViewNames.NER_ONTONOTES.equals(getViewName()))
nerRm = new NerOntonotesConfigurator().getConfig(nerRm);
else
nerRm = new NerBaseConfigurator().getConfig(nerRm);
ParametersForLbjCode.currentParameters.forceNewSentenceOnLineBreaks = false;
Parameters.readConfigAndLoadExternalData(nerRm);
// logger.info("Reading model file: {}",
// ParametersForLbjCode.currentParameters.pathToModelFile + ".level1");
NETaggerLevel1 tagger1 = new NETaggerLevel1(ParametersForLbjCode.currentParameters.pathToModelFile + ".level1", ParametersForLbjCode.currentParameters.pathToModelFile + ".level1.lex");
NETaggerLevel2 tagger2 = null;
if (ParametersForLbjCode.currentParameters.featuresToUse.containsKey("PredictionsLevel1")) {
// logger.info("Reading model file: {}",
// ParametersForLbjCode.currentParameters.pathToModelFile + ".level2");
tagger2 = new NETaggerLevel2(ParametersForLbjCode.currentParameters.pathToModelFile + ".level2", ParametersForLbjCode.currentParameters.pathToModelFile + ".level2.lex");
}
this.t1 = tagger1;
this.t2 = tagger2;
}
Aggregations