Class NGramTokenFilter
Tokenizes the input into n-grams of the given size(s).
You must specify the required Lucene.
- handles supplementary characters correctly,
- emits all n-grams for the same token at the same position,
- does not modify offsets,
- sorts n-grams by their offset in the original token first, then increasing length (meaning that "abc" will give "a", "ab", "abc", "b", "bc", "c").
You can make this filter use the old behavior by providing a version <
LUCENE_44 in the constructor but this is not recommended as
it will lead to broken Lucene.
If you were using this Lucene.
Inheritance
Implements
Inherited Members
Namespace: Lucene.Net.Analysis.NGram
Assembly: Lucene.Net.Analysis.Common.dll
Syntax
public sealed class NGramTokenFilter : TokenFilter, IDisposable
Constructors
| Improve this Doc View SourceNGramTokenFilter(LuceneVersion, TokenStream)
Creates NGram
Declaration
public NGramTokenFilter(LuceneVersion version, TokenStream input)
Parameters
Type | Name | Description |
---|---|---|
Lucene. |
version | Lucene version to enable correct position increments.
See NGram |
Lucene. |
input | Lucene. |
NGramTokenFilter(LuceneVersion, TokenStream, Int32, Int32)
Creates NGram
Declaration
public NGramTokenFilter(LuceneVersion version, TokenStream input, int minGram, int maxGram)
Parameters
Type | Name | Description |
---|---|---|
Lucene. |
version | Lucene version to enable correct position increments.
See NGram |
Lucene. |
input | Lucene. |
System. |
minGram | the smallest n-gram to generate |
System. |
maxGram | the largest n-gram to generate |
Fields
| Improve this Doc View SourceDEFAULT_MAX_NGRAM_SIZE
Declaration
public const int DEFAULT_MAX_NGRAM_SIZE = 2
Field Value
Type | Description |
---|---|
System. |
DEFAULT_MIN_NGRAM_SIZE
Declaration
public const int DEFAULT_MIN_NGRAM_SIZE = 1
Field Value
Type | Description |
---|---|
System. |
Methods
| Improve this Doc View SourceIncrementToken()
Returns the next token in the stream, or null at EOS.
Declaration
public override sealed bool IncrementToken()
Returns
Type | Description |
---|---|
System. |
Overrides
Reset()
Declaration
public override void Reset()