use of info.ephyra.util.Properties in project lucida by claritylab.
the class FeatureExtractorFactory method getInstance.
public static FeatureExtractor getInstance(Language language) throws Exception {
FeatureExtractor extractor = null;
Properties properties = propertyMap.get(language.toString());
String extractorType = properties.getProperty("extractorType");
if (extractorType == null)
throw new Exception("Required property extractorType is undefined for language" + language);
extractor = (FeatureExtractor) Class.forName(extractorType).newInstance();
extractor.initialize();
return extractor;
}
use of info.ephyra.util.Properties in project lucida by claritylab.
the class HybridQuestionClassifier method initialize.
public void initialize() throws Exception {
// return if already initialized
if (isInitialized())
return;
if (languagePair == null)
throw new Exception("languagePair must be set before calling initialize");
super.initialize();
Properties properties = Properties.loadFromClassName(this.getClass().getName());
properties = properties.mapProperties().get(languagePair.getFirst() + "_" + languagePair.getSecond());
String classifierClassNames = properties.get("classifierTypes").trim();
if (classifierClassNames == null)
throw new RuntimeException("Required property classifierTypes is undefined");
String[] classNames = classifierClassNames.split(",");
classifiers = new ArrayList<QuestionClassifier>();
for (String className : classNames) {
QuestionClassifier classifier = (QuestionClassifier) Class.forName(className).newInstance();
classifier.setLanguagePair(languagePair);
classifier.initialize();
classifiers.add(classifier);
}
String mergeResultsStr = properties.get("mergeResults").trim();
if (mergeResultsStr == null)
throw new RuntimeException("Required property mergeResults is undefined");
mergeResults = Boolean.parseBoolean(mergeResultsStr);
String confidenceThresholdStr = properties.get("confidenceThreshold").trim();
if (mergeResultsStr == null)
throw new RuntimeException("Required property confidenceThreshold is undefined");
confidenceThreshold = Double.parseDouble(confidenceThresholdStr);
setInitialized(true);
}
use of info.ephyra.util.Properties in project lucida by claritylab.
the class RuleBasedQuestionClassifier method initialize.
public void initialize() throws Exception {
if (isInitialized())
return;
if (languagePair == null)
throw new Exception("languagePair must be set before calling initialize");
super.initialize();
Properties properties = Properties.loadFromClassName(this.getClass().getName());
properties = properties.mapProperties().get(languagePair.getFirst() + "_" + languagePair.getSecond());
String rulesFileName = properties.get("rulesFile");
if (rulesFileName == null)
throw new RuntimeException("Required property rulesFile is undefined'");
rules = new ArrayList<Rule>();
loadRulesFile(rulesFileName);
setInitialized(true);
}
use of info.ephyra.util.Properties in project lucida by claritylab.
the class TrainedQuestionClassifier method initialize.
public void initialize() throws Exception {
// return if already initialized
if (isInitialized())
return;
if (languagePair == null)
throw new Exception("languagePair must be set before calling initialize");
super.initialize();
Properties properties = Properties.loadFromClassName(this.getClass().getName());
properties = properties.mapProperties().get(languagePair.getFirst() + "_" + languagePair.getSecond());
String classifierFileName = properties.get("classifierFile");
if (classifierFileName == null)
throw new RuntimeException("Required property classifierFile is undefined'");
classifier = (Classifier) IOUtil.loadSerialized(new File(classifierFileName));
setInitialized(true);
}
use of info.ephyra.util.Properties in project lucida by claritylab.
the class StanfordParser method initialize.
/**
* Initializes static resources.
*
* @throws Exception
*/
public static void initialize() throws Exception {
if (parser != null)
return;
Properties properties = Properties.loadFromClassName(StanfordParser.class.getName());
tlp = new PennTreebankLanguagePack();
String modelFile = properties.getProperty("modelFile");
if (modelFile == null)
throw new Exception("Required property '" + "modelFile' is undefined");
parser = new LexicalizedParser(modelFile);
}
Aggregations