Search in sources :

Example 1 with HashDictionary

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

the class RegExMatcher method getDictionary.

/**	load a gazetteer
	 * @param	name	the name of the list to be loaded
	 * @return the gazetteer with the specified name, packe in a HashSet for faste lookup 
	 */
public static HashDictionary getDictionary(String name) {
    if (dictionariesByName.containsKey(name))
        return dictionariesByName.get(name);
    HashDictionary dictionary = null;
    try {
        dictionary = new HashDictionary("./res/nlp/netagger/lists/" + name);
    } catch (IOException e) {
        MsgPrinter.printErrorMsg("File not found: " + name);
        dictionary = new HashDictionary();
    }
    dictionariesByName.put(name, dictionary);
    return dictionary;
}
Also used : HashDictionary(info.ephyra.util.HashDictionary) IOException(java.io.IOException)

Example 2 with HashDictionary

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

the class QuestionInterpreter method addKeywords.

/**
	 * Adds the keywords in a descriptor of a question pattern to the dictionary
	 * for the respective PROPERTY.
	 * 
	 * @param expr pattern descriptor 
	 * @param prop PROPERTY the question pattern belongs to
	 */
private static void addKeywords(String expr, String prop) {
    // tokenize expr, delimiters are meta-characters, '<', '>' and blank
    StringTokenizer st = new StringTokenizer(expr, "\\|*+?.^$(){}[]<> ");
    String token;
    HashDictionary dict;
    while (st.hasMoreTokens()) {
        token = st.nextToken();
        if (token.length() > 2 && !FunctionWords.lookup(token)) {
            // token has a length of at least 3 and is not a function word
            dict = keywords.get(prop);
            if (dict == null) {
                // new dictionary
                dict = new HashDictionary();
                keywords.put(prop, dict);
            }
            // add token to the dictionary
            dict.add(token);
        }
    }
}
Also used : StringTokenizer(java.util.StringTokenizer) HashDictionary(info.ephyra.util.HashDictionary)

Aggregations

HashDictionary (info.ephyra.util.HashDictionary)2 IOException (java.io.IOException)1 StringTokenizer (java.util.StringTokenizer)1