Search in sources :

Example 1 with Properties

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;
}
Also used : Properties(info.ephyra.util.Properties)

Example 2 with Properties

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);
}
Also used : Properties(info.ephyra.util.Properties) QuestionClassifier(info.ephyra.questionanalysis.atype.QuestionClassifier)

Example 3 with Properties

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);
}
Also used : Properties(info.ephyra.util.Properties)

Example 4 with Properties

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);
}
Also used : Properties(info.ephyra.util.Properties) File(java.io.File)

Example 5 with Properties

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);
}
Also used : LexicalizedParser(edu.stanford.nlp.parser.lexparser.LexicalizedParser) Properties(info.ephyra.util.Properties) PennTreebankLanguagePack(edu.stanford.nlp.trees.PennTreebankLanguagePack)

Aggregations

Properties (info.ephyra.util.Properties)9 BufferedReader (java.io.BufferedReader)2 FileInputStream (java.io.FileInputStream)2 FileReader (java.io.FileReader)2 Tree (edu.cmu.lti.chineseNLP.util.Tree)1 LexicalizedParser (edu.stanford.nlp.parser.lexparser.LexicalizedParser)1 PennTreebankLanguagePack (edu.stanford.nlp.trees.PennTreebankLanguagePack)1 QuestionClassifier (info.ephyra.questionanalysis.atype.QuestionClassifier)1 File (java.io.File)1