public void loadStopWords(InputStream wordfile,
String encoding) {
if ( wordfile == null ) {
stoptable = new HashSet();
return;
}
try {
// clear any previous table (if present)
stoptable = new HashSet();
InputStreamReader isr;
if (encoding == null)
isr = new InputStreamReader(wordfile);
else
isr = new InputStreamReader(wordfile, encoding);
LineNumberReader lnr = new LineNumberReader(isr);
String word;
while ( ( word = lnr.readLine() ) != null ) {
stoptable.add(word);
}
} catch ( IOException e ) {
stoptable = null;
}
}
Loads stopwords hash from resource stream (file, database...). |