C# Class Lucene.Net.Analysis.MockAnalyzer

Analyzer for testing

this analyzer is a replacement for Whitespace/Simple/KeywordAnalyzers for unit tests. If you are testing a custom component such as a queryparser or analyzer-wrapper that consumes analysis streams, its a great idea to test it with this analyzer instead. MockAnalyzer has the following behavior:

  • By default, the assertions in MockTokenizer are turned on for extra checks that the consumer is consuming properly. These checks can be disabled with #setEnableChecks(boolean).
  • Payload data is randomly injected into the stream for more thorough testing of payloads.
Inheritance: Analyzer
Mostrar archivo Open project: paulirwin/lucene.net Class Usage Examples

Public Methods

Method Description
CreateComponents ( string fieldName, TextReader reader ) : TokenStreamComponents
GetOffsetGap ( string fieldName ) : int

Get the offset gap between tokens in fields if several fields with the same name were added.

GetPositionIncrementGap ( string fieldName ) : int
MockAnalyzer ( Random random ) : System

Create a Whitespace-lowercasing analyzer with no stopwords removal.

Calls {@link #MockAnalyzer(Random, CharacterRunAutomaton, boolean, CharacterRunAutomaton) MockAnalyzer(random, MockTokenizer.WHITESPACE, true, MockTokenFilter.EMPTY_STOPSET, false}).

MockAnalyzer ( Random random, CharacterRunAutomaton runAutomaton, bool lowerCase ) : System

Calls {@link #MockAnalyzer(Random, CharacterRunAutomaton, boolean, CharacterRunAutomaton) MockAnalyzer(random, runAutomaton, lowerCase, MockTokenFilter.EMPTY_STOPSET, false}).

MockAnalyzer ( Random random, CharacterRunAutomaton runAutomaton, bool lowerCase, CharacterRunAutomaton filter ) : System

Creates a new MockAnalyzer.

Private Methods

Method Description
MaybePayload ( Lucene.Net.Analysis.TokenFilter stream, string fieldName ) : Lucene.Net.Analysis.TokenFilter

Method Details

CreateComponents() public method

public CreateComponents ( string fieldName, TextReader reader ) : TokenStreamComponents
fieldName string
reader System.IO.TextReader
return TokenStreamComponents

GetOffsetGap() public method

Get the offset gap between tokens in fields if several fields with the same name were added.
public GetOffsetGap ( string fieldName ) : int
fieldName string Currently not used, the same offset gap is returned for each field.
return int

GetPositionIncrementGap() public method

public GetPositionIncrementGap ( string fieldName ) : int
fieldName string
return int

MockAnalyzer() public method

Create a Whitespace-lowercasing analyzer with no stopwords removal.

Calls {@link #MockAnalyzer(Random, CharacterRunAutomaton, boolean, CharacterRunAutomaton) MockAnalyzer(random, MockTokenizer.WHITESPACE, true, MockTokenFilter.EMPTY_STOPSET, false}).

public MockAnalyzer ( Random random ) : System
random System.Random
return System

MockAnalyzer() public method

Calls {@link #MockAnalyzer(Random, CharacterRunAutomaton, boolean, CharacterRunAutomaton) MockAnalyzer(random, runAutomaton, lowerCase, MockTokenFilter.EMPTY_STOPSET, false}).
public MockAnalyzer ( Random random, CharacterRunAutomaton runAutomaton, bool lowerCase ) : System
random System.Random
runAutomaton CharacterRunAutomaton
lowerCase bool
return System

MockAnalyzer() public method

Creates a new MockAnalyzer.
public MockAnalyzer ( Random random, CharacterRunAutomaton runAutomaton, bool lowerCase, CharacterRunAutomaton filter ) : System
random System.Random Random for payloads behavior
runAutomaton CharacterRunAutomaton DFA describing how tokenization should happen (e.g. [a-zA-Z]+)
lowerCase bool true if the tokenizer should lowercase terms
filter CharacterRunAutomaton DFA describing how terms should be filtered (set of stopwords, etc)
return System