org.apache.lucene.analysis
Class LetterTokenizer

java.lang.Object
  extended by org.apache.lucene.util.AttributeSource
      extended by org.apache.lucene.analysis.TokenStream
          extended by org.apache.lucene.analysis.Tokenizer
              extended by org.apache.lucene.analysis.CharTokenizer
                  extended by org.apache.lucene.analysis.LetterTokenizer
All Implemented Interfaces:
Closeable
Direct Known Subclasses:
ArabicLetterTokenizer, LowerCaseTokenizer

public class LetterTokenizer
extends CharTokenizer

A LetterTokenizer is a tokenizer that divides text at non-letters. That's to say, it defines tokens as maximal strings of adjacent letters, as defined by java.lang.Character.isLetter() predicate.

Note: this does a decent job for most European languages, but does a terrible job for some Asian languages, where words are not separated by spaces.

You must specify the required Version compatibility when creating LetterTokenizer:


Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.lucene.util.AttributeSource
AttributeSource.AttributeFactory, AttributeSource.State
 
Field Summary
 
Fields inherited from class org.apache.lucene.analysis.Tokenizer
input
 
Constructor Summary
LetterTokenizer(AttributeSource.AttributeFactory factory, Reader in)
          Deprecated. use LetterTokenizer(Version, AttributeSource.AttributeFactory, Reader) instead. This will be removed in Lucene 4.0.
LetterTokenizer(AttributeSource source, Reader in)
          Deprecated. use LetterTokenizer(Version, AttributeSource, Reader) instead. This will be removed in Lucene 4.0.
LetterTokenizer(Reader in)
          Deprecated. use LetterTokenizer(Version, Reader) instead. This will be removed in Lucene 4.0.
LetterTokenizer(Version matchVersion, AttributeSource.AttributeFactory factory, Reader in)
          Construct a new LetterTokenizer using a given AttributeSource.AttributeFactory.
LetterTokenizer(Version matchVersion, AttributeSource source, Reader in)
          Construct a new LetterTokenizer using a given AttributeSource.
LetterTokenizer(Version matchVersion, Reader in)
          Construct a new LetterTokenizer.
 
Method Summary
protected  boolean isTokenChar(int c)
          Collects only characters which satisfy Character.isLetter(int).
 
Methods inherited from class org.apache.lucene.analysis.CharTokenizer
end, incrementToken, isTokenChar, normalize, normalize, reset
 
Methods inherited from class org.apache.lucene.analysis.Tokenizer
close, correctOffset
 
Methods inherited from class org.apache.lucene.analysis.TokenStream
reset
 
Methods inherited from class org.apache.lucene.util.AttributeSource
addAttribute, addAttributeImpl, captureState, clearAttributes, cloneAttributes, copyTo, equals, getAttribute, getAttributeClassesIterator, getAttributeFactory, getAttributeImplsIterator, hasAttribute, hasAttributes, hashCode, reflectAsString, reflectWith, restoreState, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LetterTokenizer

public LetterTokenizer(Version matchVersion,
                       Reader in)
Construct a new LetterTokenizer.

Parameters:
matchVersion - Lucene version to match See above
in - the input to split up into tokens

LetterTokenizer

public LetterTokenizer(Version matchVersion,
                       AttributeSource source,
                       Reader in)
Construct a new LetterTokenizer using a given AttributeSource.

Parameters:
matchVersion - Lucene version to match See above
source - the attribute source to use for this Tokenizer
in - the input to split up into tokens

LetterTokenizer

public LetterTokenizer(Version matchVersion,
                       AttributeSource.AttributeFactory factory,
                       Reader in)
Construct a new LetterTokenizer using a given AttributeSource.AttributeFactory.

Parameters:
matchVersion - Lucene version to match See above
factory - the attribute factory to use for this Tokenizer
in - the input to split up into tokens

LetterTokenizer

@Deprecated
public LetterTokenizer(Reader in)
Deprecated. use LetterTokenizer(Version, Reader) instead. This will be removed in Lucene 4.0.

Construct a new LetterTokenizer.


LetterTokenizer

@Deprecated
public LetterTokenizer(AttributeSource source,
                                  Reader in)
Deprecated. use LetterTokenizer(Version, AttributeSource, Reader) instead. This will be removed in Lucene 4.0.

Construct a new LetterTokenizer using a given AttributeSource.


LetterTokenizer

@Deprecated
public LetterTokenizer(AttributeSource.AttributeFactory factory,
                                  Reader in)
Deprecated. use LetterTokenizer(Version, AttributeSource.AttributeFactory, Reader) instead. This will be removed in Lucene 4.0.

Construct a new LetterTokenizer using a given AttributeSource.AttributeFactory.

Method Detail

isTokenChar

protected boolean isTokenChar(int c)
Collects only characters which satisfy Character.isLetter(int).

Overrides:
isTokenChar in class CharTokenizer


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