edu.stanford.nlp.process
Class WhitespaceTokenizer
java.lang.Object
edu.stanford.nlp.process.AbstractTokenizer<Word>
edu.stanford.nlp.process.WhitespaceTokenizer
- All Implemented Interfaces:
- Tokenizer<Word>, Iterator<Word>
public class WhitespaceTokenizer
- extends AbstractTokenizer<Word>
A WhitespaceTokenizer is a tokenizer that splits on and discards only
whitespace characters.
This implementation returns Word objects. It has a parameter for whether
to make EOL a token or whether to treat EOL characters as whitespace.
If an EOL is a token, the class returns it as a Word with String value "\n".
Implementation note: This was rewritten in Apr 2006 to discard the
old StreamTokenizer based implementation and to replace it with a
Unicode compliant JFlex-based version.
- Author:
- Joseph Smarr (jsmarr@stanford.edu), Teg Grenager (grenager@stanford.edu), Roger Levy, Christopher Manning
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WhitespaceTokenizer
public WhitespaceTokenizer(Reader r)
- Constructs a new WhitespaceTokenizer with the Reader r as its source.
WhitespaceTokenizer
public WhitespaceTokenizer(Reader r,
boolean eolIsSignificant)
- Constructs a new WhitespaceTokenizer with the Reader r as its source.
getNext
protected Word getNext()
- Internally fetches the next token.
- Specified by:
getNext
in class AbstractTokenizer<Word>
- Returns:
- the next token in the token stream, or null if none exists.
factory
public static TokenizerFactory factory()
factory
public static TokenizerFactory factory(boolean eolIsSignificant)
main
public static void main(String[] args)
throws IOException
- Reads a file from the argument and prints its tokens one per line.
This is mainly as a testing aid, but it can also be quite useful
standalone to turn a corpus into a one token per line file of tokens.
Usage:
java edu.stanford.nlp.process.WhitespaceTokenizer filename
- Parameters:
args
- Command line arguments
- Throws:
IOException
Stanford NLP Group