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;
}
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);
}
}
}
Aggregations