lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Weissman <>
Subject StrictAnalyzer Proposal
Date Tue, 19 Feb 2002 20:02:16 GMT
Everyone - 

I was told to post any proposed Lucene changes/additions to the list, so
here goes:

(1)I rewrote StandardAnalyzer as StrictAnalyzer for the project I am working
on.  StandardAnalyzer does not filter enough words for my liking.
Basically all I did was add to the STOP_WORDS array.  The stop words I added
are based on the default values in SQL Server 2000's text indexing.  (Source
code below)

(2)I would also like to propose a change to StandardTokenizer which supports
strings with a trailing and/or leading comma(s) such as "therefore," and
",ice,".  Currently StandardTokenizer is not returning any results for some
of my most basic searches because of commas adjacent to words.

Comments, suggestions, questions?


import org.apache.lucene.analysis.*;
import java.util.Hashtable;

/** Filters {@link StandardTokenizer} with {@link StandardFilter}, {@link
 * LowerCaseFilter} and {@link StopFilter}. */
public final class StrictAnalyzer extends Analyzer {
  private Hashtable stopTable;

  /** An array containing some common English words that are not usually
    for searching. */
  public static final String[] STOP_WORDS = {
    "about",  "after",  "all", "also",  "an",  "and", 
    "another", "any", "are", "as", "at", "be", "because",
    "been", "before", "being", "between", "both", "but",


  /** Builds an analyzer. */
  public StrictAnalyzer() {

  /** Builds an analyzer with the given stop words. */
  public StrictAnalyzer(String[] stopWords) {
    stopTable = StopFilter.makeStopTable(stopWords);

  /** Constructs a {@link StandardTokenizer} filtered by a {@link
   * StandardFilter}, a {@link LowerCaseFilter} and a {@link StopFilter}. */
  public final TokenStream tokenStream(String fieldName, Reader reader) {
    TokenStream result = new StandardTokenizer(reader);
    result = new StandardFilter(result);
    result = new LowerCaseFilter(result);
    result = new StopFilter(result, stopTable);
    return result;

To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message