Methods Summary |
---|
public static java.util.HashMap | getStemDict(java.io.File wordstemfile)Reads a stemsdictionary. Each line contains:
word \t stem
i.e. tab seperated)
if (wordstemfile == null) {
return new HashMap();
}
HashMap result = new HashMap();
try {
LineNumberReader lnr = new LineNumberReader(new FileReader(wordstemfile));
String line;
String[] wordstem;
while ((line = lnr.readLine()) != null) {
wordstem = line.split("\t", 2);
result.put(wordstem[0], wordstem[1]);
}
} catch (IOException e) {
}
return result;
|
public static java.util.HashMap | getWordtable(java.lang.String path, java.lang.String wordfile)
if (path == null || wordfile == null) {
return new HashMap();
}
return getWordtable(new File(path, wordfile));
|
public static java.util.HashMap | getWordtable(java.lang.String wordfile)
if (wordfile == null) {
return new HashMap();
}
return getWordtable(new File(wordfile));
|
public static java.util.HashMap | getWordtable(java.io.File wordfile)
if (wordfile == null) {
return new HashMap();
}
HashMap result = null;
try {
LineNumberReader lnr = new LineNumberReader(new FileReader(wordfile));
String word = null;
String[] stopwords = new String[100];
int wordcount = 0;
while ((word = lnr.readLine()) != null) {
wordcount++;
if (wordcount == stopwords.length) {
String[] tmp = new String[stopwords.length + 50];
System.arraycopy(stopwords, 0, tmp, 0, wordcount);
stopwords = tmp;
}
stopwords[wordcount - 1] = word;
}
result = makeWordTable(stopwords, wordcount);
}
// On error, use an empty table
catch (IOException e) {
result = new HashMap();
}
return result;
|
private static java.util.HashMap | makeWordTable(java.lang.String[] words, int length)Builds the wordlist table.
HashMap table = new HashMap(length);
for (int i = 0; i < length; i++) {
table.put(words[i], words[i]);
}
return table;
|