Class: Ferret::Analysis::StopAnalyzer

Inherits:
Analyzer
  • Object
show all
Defined in:
lib/ferret/analysis/analyzers.rb

Overview

Filters LetterTokenizer with LowerCaseFilter and StopFilter.

Direct Known Subclasses

StandardAnalyzer

Constant Summary collapse

ENGLISH_STOP_WORDS =

An array containing some common English words that are not usually useful for searching.

[
  "a", "an", "and", "are", "as", "at", "be", "but", "by", "for", "if",
  "in", "into", "is", "it", "no", "not", "of", "on", "or", "s", "such",
  "t", "that", "the", "their", "then", "there", "these",
  "they", "this", "to", "was", "will", "with"
]

Instance Method Summary collapse

Methods inherited from Analyzer

#position_increment_gap

Constructor Details

#initialize(stop_words = ENGLISH_STOP_WORDS) ⇒ StopAnalyzer

Builds an analyzer which removes words in the provided array.



60
61
62
# File 'lib/ferret/analysis/analyzers.rb', line 60

def initialize(stop_words = ENGLISH_STOP_WORDS)
  @stop_words = stop_words
end

Instance Method Details

#token_stream(field, string) ⇒ Object

Filters LowerCaseTokenizer with StopFilter.



65
66
67
# File 'lib/ferret/analysis/analyzers.rb', line 65

def token_stream(field, string)
  return StopFilter.new(LowerCaseTokenizer.new(string), @stop_words)
end