Search in sources :

Example 6 with Properties

use of info.ephyra.util.Properties in project lucida by claritylab.

the class FocusFinder method initialize.

/**
     * Initializes static resources. The input properties which must be defined are:
     * <ul>
     *   <li> edu.cmu.lti.javelin.qa.english.FocusFinder.treeTemplatesFile : &nbsp; 
     *   the location of a file containing tree templates to use.  Each tree template
     *   must be specified on one line.  Blank lines and lines beginning with "#" 
     *   are ignored.  A tree template is a parenthesized syntactic parse tree which
     *   can be used as an underspecified template tree to unify with a real syntactic
     *   parse tree.  See {@link edu.cmu.lti.chineseNLP.util.TreeHelper#extractNode 
     *   TreeHelper.extractNode} for more details.
     * </ul>
     * @throws Exception if the required input property is not defined
     */
public static void initialize() throws Exception {
    // return if already initialized
    if (isInitialized())
        return;
    Properties properties = Properties.loadFromClassName(FocusFinder.class.getName());
    // initialize JWNL
    if (!JWNL.isInitialized()) {
        String file_properties = System.getProperty("jwnl.configuration");
        if (file_properties == null)
            throw new Exception("Required property 'jwnl.configuration' is undefined");
        JWNL.initialize(new FileInputStream(file_properties));
    }
    // load tree templates file
    treeTemplatesFile = properties.getProperty("treeTemplatesFile");
    if (treeTemplatesFile == null)
        throw new Exception("Required property treeTemplatesFile is undefined");
    BufferedReader in = new BufferedReader(new FileReader(treeTemplatesFile));
    String line;
    treeTemplates = new ArrayList<Tree>();
    while ((line = in.readLine()) != null) {
        if (line.matches("#.*") || line.matches("\\s*"))
            continue;
        treeTemplates.add(TreeHelper.buildTree(line, Tree.ENGLISH));
    }
    in.close();
    setInitialized(true);
}
Also used : BufferedReader(java.io.BufferedReader) Tree(edu.cmu.lti.chineseNLP.util.Tree) FileReader(java.io.FileReader) Properties(info.ephyra.util.Properties) FileInputStream(java.io.FileInputStream)

Example 7 with Properties

use of info.ephyra.util.Properties in project lucida by claritylab.

the class QuestionClassifierFactory method getInstance.

/**
     * Returns a QuestionClassifier for the specified Language Pair. Configure which
     * QuestionClassifier is associated with each Language Pair in this class's properties 
     * file.
     */
public static QuestionClassifier getInstance(Pair<Language, Language> languagePair) throws Exception {
    QuestionClassifier classifier = null;
    Properties properties = propertyMap.get(languagePair.getFirst() + "_" + languagePair.getSecond());
    String classifierType = properties.getProperty("classifierType");
    if (classifierType == null)
        throw new Exception("Required property classifierType is undefined for language pair " + languagePair);
    classifier = (QuestionClassifier) Class.forName(classifierType).newInstance();
    classifier.setLanguagePair(languagePair);
    classifier.initialize();
    return classifier;
}
Also used : Properties(info.ephyra.util.Properties)

Example 8 with Properties

use of info.ephyra.util.Properties in project lucida by claritylab.

the class WordNetAnswerTypeMapping method initialize.

/**
     * Initializes static resources.  The input properties that must be defined are:
     * <ul>
     *   <li>jwnl.configuration : </p>&nbsp; the location of the configuration file for JWNL
     *   <li>edu.cmu.lti.javelin.qa.english.WordNetAnswerTypeMapping.mapFile :
     *   <p>&nbsp; the location of the file specifying a mapping from WordNet synsets
     *   to answer subtypes.  The one-to-many mapping must be specified  
     *   one element per line, with the domain and range values separated by a comma. 
     *   Blank lines and lines beginning with "#" are ignored.  WordNet synsets must be
     *   represented by concatenating the list of lemmas in the synset, separating them 
     *   with a dash ("-"), followed by another "-" and the database file offset of the synset.
     *   (Note: this offset value will vary with the version of WordNet used.)</p>
     *   &nbsp; Thus, an example of an element of the mapping is:</p>
     *     <code>body_of_water-water-8651117,ocean</code>
     * </ul>
     * @throws Exception if one of the required properties is not defined.
     */
public static void initialize() throws Exception {
    if (isInitialized())
        return;
    if (!JWNL.isInitialized()) {
        String file_properties = System.getProperty("jwnl.configuration");
        if (file_properties == null)
            throw new Exception("Required property 'jwnl.configuration' is undefined");
        JWNL.initialize(new FileInputStream(file_properties));
    }
    pUtils = PointerUtils.getInstance();
    Properties properties = Properties.loadFromClassName(WordNetAnswerTypeMapping.class.getName());
    String wnAtypeMapFile = properties.getProperty("mapFile");
    if (wnAtypeMapFile == null)
        throw new RuntimeException("Required parameter mapFile is undefined");
    BufferedReader in = new BufferedReader(new FileReader(wnAtypeMapFile));
    String line;
    wnAtypeMap = new HashMap<String, String>();
    wnAtypeMapKeys = new ArrayList<String>();
    while ((line = in.readLine()) != null) {
        if (line.matches("#.*") || line.matches("\\s*"))
            continue;
        String[] strs = line.split(",");
        wnAtypeMap.put(strs[0], strs[1]);
        wnAtypeMapKeys.add(strs[0]);
    }
    in.close();
    setInitialized(true);
}
Also used : BufferedReader(java.io.BufferedReader) FileReader(java.io.FileReader) Properties(info.ephyra.util.Properties) FileInputStream(java.io.FileInputStream)

Example 9 with Properties

use of info.ephyra.util.Properties in project lucida by claritylab.

the class FeatureExtractor method initialize.

/**
     * Reads in properties from this class's properties file and sets class data members.
     * 
     * @throws Exception
     */
public void initialize() throws Exception {
    Properties properties = Properties.loadFromClassName(FeatureExtractor.class.getName());
    String classLevelsProp = properties.getProperty("classLevels");
    if (classLevelsProp == null)
        throw new RuntimeException("Required parameter classLevels is undefined");
    classLevels = Integer.parseInt(classLevelsProp);
    String useClassLevelsProp = properties.getProperty("useClassLevels");
    if (useClassLevelsProp == null)
        throw new RuntimeException("Required parameter useClassLevels is undefined");
    useClassLevels = Boolean.parseBoolean(useClassLevelsProp);
}
Also used : Properties(info.ephyra.util.Properties)

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