Methods Summary |
---|
public static java.util.HashSet | getWordSet(java.io.File wordfile)Loads a text file and adds every line as an entry to a HashSet (omitting
leading and trailing whitespace). Every line of the file should contain only
one word. The words need to be in lowercase if you make use of an
Analyzer which uses LowerCaseFilter (like GermanAnalyzer).
HashSet result = new HashSet();
FileReader freader = null;
LineNumberReader lnr = null;
try {
freader = new FileReader(wordfile);
lnr = new LineNumberReader(freader);
String word = null;
while ((word = lnr.readLine()) != null) {
result.add(word.trim());
}
}
finally {
if (lnr != null)
lnr.close();
if (freader != null)
freader.close();
}
return result;
|
public static java.util.Hashtable | getWordtable(java.lang.String path, java.lang.String wordfile)
return getWordtable(new File(path, wordfile));
|
public static java.util.Hashtable | getWordtable(java.lang.String wordfile)
return getWordtable(new File(wordfile));
|
public static java.util.Hashtable | getWordtable(java.io.File wordfile)
HashSet wordSet = (HashSet)getWordSet(wordfile);
Hashtable result = makeWordTable(wordSet);
return result;
|
private static java.util.Hashtable | makeWordTable(java.util.HashSet wordSet)Builds a wordlist table, using words as both keys and values
for backward compatibility.
Hashtable table = new Hashtable();
for (Iterator iter = wordSet.iterator(); iter.hasNext();) {
String word = (String)iter.next();
table.put(word, word);
}
return table;
|