## org.apache.lucene.analysis.shingle
Class ShingleAnalyzerWrapper

    java.lang.Object
      org.apache.lucene.analysis.Analyzer
          org.apache.lucene.analysis.shingle.ShingleAnalyzerWrapper

    public class ShingleAnalyzerWrapper

extends Analyzer

A ShingleAnalyzerWrapper wraps a `ShingleFilter` around another `Analyzer`.

A shingle is another name for a token based n-gram.

Field Summary
`protected Analyzer` `defaultAnalyzer`
`protected int` `maxShingleSize`
`protected boolean` `outputUnigrams`

Fields inherited from class org.apache.lucene.analysis.Analyzer
`overridesTokenStreamMethod`

Constructor Summary
`ShingleAnalyzerWrapper()` Wraps `StandardAnalyzer`.
`ShingleAnalyzerWrapper(Analyzer defaultAnalyzer)`
`ShingleAnalyzerWrapper(Analyzer defaultAnalyzer, int maxShingleSize)`
`ShingleAnalyzerWrapper(int nGramSize)`

Method Summary
`int` `getMaxShingleSize()` The max shingle (ngram) size
`boolean` `isOutputUnigrams()`
`TokenStream` `reusableTokenStream(java.lang.String fieldName, java.io.Reader reader)` Creates a TokenStream that is allowed to be re-used from the previous time that the same thread called this method.
`void` `setMaxShingleSize(int maxShingleSize)` Set the maximum size of output shingles
`void` `setOutputUnigrams(boolean outputUnigrams)` Shall the filter pass the original tokens (the "unigrams") to the output stream?
`TokenStream` `tokenStream(java.lang.String fieldName, java.io.Reader reader)` Creates a TokenStream which tokenizes all the text in the provided Reader.

Methods inherited from class org.apache.lucene.analysis.Analyzer
`close, getOffsetGap, getPositionIncrementGap, getPreviousTokenStream, setOverridesTokenStreamMethod, setPreviousTokenStream`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### defaultAnalyzer

    protected Analyzer defaultAnalyzer

### maxShingleSize

    protected int maxShingleSize

### outputUnigrams

    protected boolean outputUnigrams

Constructor Detail

### ShingleAnalyzerWrapper

    public ShingleAnalyzerWrapper(Analyzer defaultAnalyzer)

### ShingleAnalyzerWrapper

    public ShingleAnalyzerWrapper(Analyzer defaultAnalyzer,
                                  int maxShingleSize)

### ShingleAnalyzerWrapper

    public ShingleAnalyzerWrapper()

  Wraps `StandardAnalyzer`.

### ShingleAnalyzerWrapper

    public ShingleAnalyzerWrapper(int nGramSize)

Method Detail

### getMaxShingleSize

    public int getMaxShingleSize()

  The max shingle (ngram) size

  Returns:
    The max shingle (ngram) size

### setMaxShingleSize

    public void setMaxShingleSize(int maxShingleSize)

  Set the maximum size of output shingles

  Parameters:
    `maxShingleSize` - max shingle size

### isOutputUnigrams

    public boolean isOutputUnigrams()

### setOutputUnigrams

    public void setOutputUnigrams(boolean outputUnigrams)

  Shall the filter pass the original tokens (the "unigrams") to the output stream?

  Parameters:
    `outputUnigrams` - Whether or not the filter shall pass the original tokens to the output stream

### tokenStream

    public TokenStream tokenStream(java.lang.String fieldName,
                                   java.io.Reader reader)

  Description copied from class: `Analyzer`
  Creates a TokenStream which tokenizes all the text in the provided Reader. Must be able to handle null field name for backward compatibility.

  Specified by:
    `tokenStream` in class `Analyzer`

### reusableTokenStream

    public TokenStream reusableTokenStream(java.lang.String fieldName,
                                           java.io.Reader reader)
                                    throws java.io.IOException

  Description copied from class: `Analyzer`
  Creates a TokenStream that is allowed to be re-used from the previous time that the same thread called this method. Callers that do not need to use more than one TokenStream at the same time from this analyzer should use this method for better performance.

  Overrides:
    `reusableTokenStream` in class `Analyzer`
  Throws:
    `java.io.IOException`

Copyright © 2000-2011 Apache Software Foundation. All Rights Reserved.