Lucene++ - a full-featured, c++ search engine
API Documentation

Public Member Functions | Static Public Member Functions | Protected Attributes
Lucene::StopFilter Class Reference

Removes stop words from a token stream. More...

`#include <StopFilter.h>`

Inheritance diagram for Lucene::StopFilter:

## Public Member Functions

| StopFilter (bool enablePositionIncrements, const TokenStreamPtr &input, HashSet< String > stopWords, bool ignoreCase=false)
| Construct a token stream filtering the given input. If stopWords is an instance of CharArraySet (true if makeStopSet() was used to construct the set) it will be directly used and ignoreCase will be ignored since CharArraySet directly controls case sensitivity. More...
| StopFilter (bool enablePositionIncrements, const TokenStreamPtr &input, const CharArraySetPtr &stopWords, bool ignoreCase=false)
virtual | ~StopFilter ()
virtual String | getClassName ()
boost::shared_ptr< StopFilter > | shared_from_this ()
virtual bool | incrementToken ()
| Returns the next input Token whose term() is not a stop word. More...
bool | getEnablePositionIncrements ()
void | setEnablePositionIncrements (bool enable)
| If true, this StopFilter will preserve positions of the incoming tokens (ie, accumulate and set position increments of the removed stop tokens). Generally, true is best as it does not lose information (positions of the original tokens) during indexing. More...
Public Member Functions inherited from Lucene::TokenFilter
virtual | ~TokenFilter ()
boost::shared_ptr< TokenFilter > | shared_from_this ()
virtual void | end ()
| Performs end-of-stream operations, if any, and calls then end() on the input TokenStream. NOTE: Be sure to call TokenFilter::end() first when overriding this method. More...
virtual void | close ()
| Close the input TokenStream. More...
virtual void | reset ()
| Reset the filter as well as the input TokenStream. More...
Public Member Functions inherited from Lucene::TokenStream
virtual | ~TokenStream ()
boost::shared_ptr< TokenStream > | shared_from_this ()
Public Member Functions inherited from Lucene::AttributeSource
| AttributeSource ()
| An AttributeSource using the default attribute factory DefaultAttributeFactory. More...
| AttributeSource (const AttributeSourcePtr &input)
| An AttributeSource that uses the same attributes as the supplied one. More...
| AttributeSource (const AttributeFactoryPtr &factory)
| An AttributeSource using the supplied AttributeFactory for creating new Attribute instances. More...
virtual | ~AttributeSource ()
boost::shared_ptr< AttributeSource > | shared_from_this ()
AttributeFactoryPtr | getAttributeFactory ()
| returns the used AttributeFactory. More...
template<class ATTR >
boost::shared_ptr< ATTR > | addAttribute ()
| This method first checks if an instance of that class is already in this AttributeSource and returns it. Otherwise a new instance is created, added to this AttributeSource and returned. More...
void | addAttribute (const String &className, const AttributePtr &attrImpl)
| Adds a custom Attribute instance. More...
bool | hasAttributes ()
| Returns true if this AttributeSource has any attributes. More...
template<class ATTR >
bool | hasAttribute ()
| Returns true, if this AttributeSource contains the passed-in Attribute. More...
template<class ATTR >
boost::shared_ptr< ATTR > | getAttribute ()
| Returns the instance of the passed in Attribute contained in this AttributeSource. More...
void | clearAttributes ()
| Resets all Attributes in this AttributeSource by calling AttributeImpl#clear() on each Attribute implementation. More...
AttributeSourceStatePtr | captureState ()
| Captures the state of all Attributes. The return value can be passed to restoreState to restore the state of this or another AttributeSource. More...
void | restoreState (const AttributeSourceStatePtr &state)

Restores this state by copying the values of all attribute implementations that this state contains into the attributes implementations of the targetStream. The targetStream must contain a corresponding instance for each argument contained in this state (eg. it is not possible to restore the state of an AttributeSource containing a TermAttribute into a AttributeSource using a Token instance as implementation). More...

virtual int32_t | hashCode ()
| Return hash code for this object. More...
virtual bool | equals (const LuceneObjectPtr &other)
| Return whether two objects are equal. More...
virtual String | toString ()
| Returns a string representation of the object. More...
AttributeSourcePtr | cloneAttributes ()
| Performs a clone of all AttributeImpl instances returned in a new AttributeSource instance. This method can be used to eg. create another TokenStream with exactly the same attributes (using {}) More...
Collection< AttributePtr > | getAttributes ()
| Return a vector of attributes based on currentState. More...
Public Member Functions inherited from Lucene::LuceneObject
virtual | ~LuceneObject ()
virtual void | initialize ()
| Called directly after instantiation to create objects that depend on this object being fully constructed. More...
virtual LuceneObjectPtr | clone (const LuceneObjectPtr &other=LuceneObjectPtr())
| Return clone of this object. More...
virtual int32_t | compareTo (const LuceneObjectPtr &other)
| Compare two objects. More...
Public Member Functions inherited from Lucene::LuceneSync
virtual | ~LuceneSync ()
virtual SynchronizePtr | getSync ()
| Return this object synchronize lock. More...
virtual LuceneSignalPtr | getSignal ()
| Return this object signal. More...
virtual void | lock (int32_t timeout=0)
| Lock this object using an optional timeout. More...
virtual void | unlock ()
| Unlock this object. More...
virtual bool | holdsLock ()
| Returns true if this object is currently locked by current thread. More...
virtual void | wait (int32_t timeout=0)
| Wait for signal using an optional timeout. More...
virtual void | notifyAll ()
| Notify all threads waiting for signal. More...

## Static Public Member Functions

static String | _getClassName ()
static HashSet< String > | makeStopSet (Collection< String > stopWords)
| Builds a Set from an array of stop words, appropriate for passing into the StopFilter constructor. More...
static bool | getEnablePositionIncrementsVersionDefault (LuceneVersion::Version matchVersion)
| Returns version-dependent default for enablePositionIncrements. Analyzers that embed StopFilter use this method when creating the StopFilter. Prior to 2.9, this returns false. On 2.9 or later, it returns true. More...
Static Public Member Functions inherited from Lucene::TokenFilter
static String | _getClassName ()
Static Public Member Functions inherited from Lucene::TokenStream
static String | _getClassName ()
Static Public Member Functions inherited from Lucene::AttributeSource
static String | _getClassName ()

## Protected Attributes

CharArraySetPtr | stopWords
bool | enablePositionIncrements
TermAttributePtr | termAtt
PositionIncrementAttributePtr | posIncrAtt
Protected Attributes inherited from Lucene::TokenFilter
TokenStreamPtr | input
| The source of tokens for this filter. More...
Protected Attributes inherited from Lucene::AttributeSource
AttributeFactoryPtr | factory
MapStringAttribute | attributes
AttributeSourceStatePtr | currentState
Protected Attributes inherited from Lucene::LuceneSync
SynchronizePtr | objectLock
LuceneSignalPtr | objectSignal

## Additional Inherited Members

Protected Member Functions inherited from Lucene::TokenFilter
| TokenFilter (const TokenStreamPtr &input)
| Construct a token stream filtering the given input. More...
Protected Member Functions inherited from Lucene::TokenStream
| TokenStream ()
| A TokenStream using the default attribute factory. More...
| TokenStream (const AttributeSourcePtr &input)
| A TokenStream that uses the same attributes as the supplied one. More...
| TokenStream (const AttributeFactoryPtr &factory)
| A TokenStream using the supplied AttributeFactory for creating new Attribute instances. More...
Protected Member Functions inherited from Lucene::AttributeSource
AttributePtr | getAttribute (const String &className)
| The caller must pass in a className value. This method checks if an instance of that class is already in this AttributeSource and returns it. More...
bool | hasAttribute (const String &className)
| Returns true, if this AttributeSource contains the passed-in Attribute. More...
void | computeCurrentState ()
Protected Member Functions inherited from Lucene::LuceneObject
| LuceneObject ()

## Detailed Description

Removes stop words from a token stream.

## Constructor & Destructor Documentation

## ◆ StopFilter() [1/2]

Lucene::StopFilter::StopFilter | ( | bool | enablePositionIncrements,
|  | const TokenStreamPtr & | input,
|  | HashSet< String > | stopWords,
|  | bool | ignoreCase = `false`
| ) |  |

Construct a token stream filtering the given input. If stopWords is an instance of CharArraySet (true if makeStopSet() was used to construct the set) it will be directly used and ignoreCase will be ignored since CharArraySet directly controls case sensitivity.

If stopWords is not an instance of CharArraySet, a new CharArraySet will be constructed and ignoreCase will be used to specify the case sensitivity of that set.

Parameters

  enablePositionIncrements | true if token positions should record the removed stop words
  input | Input TokenStream
  stopWords | A Set of Strings or char[] or any other toString()-able set representing the stopwords
  ignoreCase | if true, all words are lower cased first

## ◆ StopFilter() [2/2]

Lucene::StopFilter::StopFilter | ( | bool | enablePositionIncrements,
|  | const TokenStreamPtr & | input,
|  | const CharArraySetPtr & | stopWords,
|  | bool | ignoreCase = `false`
| ) |  |

## ◆ ~StopFilter()

virtual Lucene::StopFilter::~StopFilter | ( |  | ) |

virtual

## Member Function Documentation

## ◆ _getClassName()

static String Lucene::StopFilter::_getClassName | ( |  | ) |

inline static

## ◆ getClassName()

virtual String Lucene::StopFilter::getClassName | ( |  | ) |

inline virtual

Reimplemented from Lucene::TokenFilter.

## ◆ getEnablePositionIncrements()

bool Lucene::StopFilter::getEnablePositionIncrements | ( |  | ) |

See also
  setEnablePositionIncrements(bool).

## ◆ getEnablePositionIncrementsVersionDefault()

static bool Lucene::StopFilter::getEnablePositionIncrementsVersionDefault | ( | LuceneVersion::Version | matchVersion | ) |

static

Returns version-dependent default for enablePositionIncrements. Analyzers that embed StopFilter use this method when creating the StopFilter. Prior to 2.9, this returns false. On 2.9 or later, it returns true.

## ◆ incrementToken()

virtual bool Lucene::StopFilter::incrementToken | ( |  | ) |

virtual

Returns the next input Token whose term() is not a stop word.

Implements Lucene::TokenStream.

## ◆ makeStopSet()

static HashSet<String> Lucene::StopFilter::makeStopSet | ( | Collection< String > | stopWords | ) |

static

Builds a Set from an array of stop words, appropriate for passing into the StopFilter constructor.

## ◆ setEnablePositionIncrements()

void Lucene::StopFilter::setEnablePositionIncrements | ( | bool | enable | ) |

If true, this StopFilter will preserve positions of the incoming tokens (ie, accumulate and set position increments of the removed stop tokens). Generally, true is best as it does not lose information (positions of the original tokens) during indexing.

When set, when a token is stopped (omitted), the position increment of the following token is incremented.

NOTE: be sure to also set QueryParser#setEnablePositionIncrements if you use QueryParser to create queries.

## ◆ shared_from_this()

boost::shared_ptr< StopFilter > Lucene::StopFilter::shared_from_this | ( |  | ) |

inline

## Field Documentation

## ◆ enablePositionIncrements

bool Lucene::StopFilter::enablePositionIncrements

protected

## ◆ posIncrAtt

PositionIncrementAttributePtr Lucene::StopFilter::posIncrAtt

protected

## ◆ stopWords

CharArraySetPtr Lucene::StopFilter::stopWords

protected

## ◆ termAtt

TermAttributePtr Lucene::StopFilter::termAtt

protected

The documentation for this class was generated from the following file:

- StopFilter.h

clucene.sourceforge.net