From 45ab072d8549b2b9f477c6b3336a2eba1c046caa Mon Sep 17 00:00:00 2001 From: Erik Hatcher Date: Mon, 19 Jan 2004 21:20:18 +0000 Subject: [PATCH] Duplicate WordlistLoader removal. It exists in Lucene's core also. git-svn-id: https://svn.apache.org/repos/asf/lucene/java/trunk@150928 13f79535-47bb-0310-9956-ffa450edef68 --- .../lucene/analysis/br/WordlistLoader.java | 85 ------------------- 1 file changed, 85 deletions(-) delete mode 100644 sandbox/contributions/analyzers/src/java/org/apache/lucene/analysis/br/WordlistLoader.java diff --git a/sandbox/contributions/analyzers/src/java/org/apache/lucene/analysis/br/WordlistLoader.java b/sandbox/contributions/analyzers/src/java/org/apache/lucene/analysis/br/WordlistLoader.java deleted file mode 100644 index d5a8cf2e6ad..00000000000 --- a/sandbox/contributions/analyzers/src/java/org/apache/lucene/analysis/br/WordlistLoader.java +++ /dev/null @@ -1,85 +0,0 @@ -package org.apache.lucene.analysis.br; - -import java.io.File; -import java.io.FileReader; -import java.io.IOException; -import java.io.LineNumberReader; -import java.util.Hashtable; - -/** - * Loads a textfile and adds every entry to a Hashtable. If a file is not found - * or on any error, an empty table is returned. - * - * @author Gerhard Schwarz - * @version $Id$ - */ -public class WordlistLoader { - - /** - * @param path Path to the wordlist. - * @param wordfile Name of the wordlist. - */ - public static Hashtable getWordtable( String path, String wordfile ) { - if ( path == null || wordfile == null ) { - return new Hashtable(); - } - File absoluteName = new File( path, wordfile ); - return getWordtable( absoluteName ); - } - /** - * @param wordfile Complete path to the wordlist - */ - public static Hashtable getWordtable( String wordfile ) { - if ( wordfile == null ) { - return new Hashtable(); - } - File absoluteName = new File( wordfile ); - return getWordtable( absoluteName ); - } - - /** - * @param wordfile File containing the wordlist. - */ - public static Hashtable getWordtable( File wordfile ) { - if ( wordfile == null ) { - return new Hashtable(); - } - Hashtable 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] = word; - } - result = makeWordTable( stopwords, wordcount ); - } - // On error, use an empty table. - catch ( IOException e ) { - result = new Hashtable(); - } - return result; - } - - /** - * Builds the wordlist table. - * - * @param words Word that where read. - * @param length Amount of words that where read into words. - */ - private static Hashtable makeWordTable( String[] words, int length ) { - Hashtable table = new Hashtable( length ); - for ( int i = 0; i < length; i++ ) { - table.put( words[i], words[i] ); - } - return table; - } -} -