SynonymTokenFilter (Lucene 2.4.1 API)
Keywords: org.apache.lucene.index.memory.SynonymTokenFilter class

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.lucene.index.memory
Class SynonymTokenFilter

    java.lang.Object
      org.apache.lucene.analysis.TokenStream
          org.apache.lucene.analysis.TokenFilter
              org.apache.lucene.index.memory.SynonymTokenFilter

    public class SynonymTokenFilter

extends TokenFilter

Injects additional tokens for synonyms of token terms fetched from the underlying child stream; the child stream must deliver lowercase tokens for synonyms to be found.

Field Summary
`static String` | `SYNONYM_TOKEN_TYPE` The Token.type used to indicate a synonym to higher level filters.

Fields inherited from class org.apache.lucene.analysis.TokenFilter
`input`

Constructor Summary
`SynonymTokenFilter(TokenStream input, SynonymMap synonyms, int maxSynonyms)` Creates an instance for the given underlying stream and synonym table.

Method Summary
`protected Token` | `createToken(String synonym, Token current, Token reusableToken)` Creates and returns a token for the given synonym of the current input token; Override for custom (stateless or stateful) behavior, if desired.
`Token` | `next(Token reusableToken)` Returns the next token in the stream, or null at EOS.

Methods inherited from class org.apache.lucene.analysis.TokenFilter
`close, reset`

Methods inherited from class org.apache.lucene.analysis.TokenStream
`next`

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

Field Detail

### SYNONYM_TOKEN_TYPE

    public static final String SYNONYM_TOKEN_TYPE

  The Token.type used to indicate a synonym to higher level filters.

  See Also:
    Constant Field Values

Constructor Detail

### SynonymTokenFilter

    public SynonymTokenFilter(TokenStream input,
                              SynonymMap synonyms,
                              int maxSynonyms)

  Creates an instance for the given underlying stream and synonym table.

  Parameters:
    `input` - the underlying child token stream
    `synonyms` - the map used to extract synonyms for terms
    `maxSynonyms` - the maximum number of synonym tokens to return per underlying token word (a value of Integer.MAX_VALUE indicates unlimited)

Method Detail

### next

    public Token next(Token reusableToken)
               throws IOException

  Returns the next token in the stream, or null at EOS.

  Overrides:
    `next` in class `TokenStream`
  Parameters:
    `reusableToken` - a Token that may or may not be used to return; this parameter should never be null (the callee is not required to check for null before using it, but it is a good idea to assert that it is not null.)
  Returns:
    next token in the stream or null if end-of-stream was hit
  Throws:
    `IOException`

### createToken

    protected Token createToken(String synonym,
                                Token current,
                                Token reusableToken)

  Creates and returns a token for the given synonym of the current input token; Override for custom (stateless or stateful) behavior, if desired.

  Parameters:
    `synonym` - a synonym for the current token's term
    `current` - the current token from the underlying child stream
    `reusableToken` - the token to reuse
  Returns:
    a new token, or null to indicate that the given synonym should be ignored

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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