Package opennlp.tools.tokenize.lang.en
Class TokenSampleStream
java.lang.Object
opennlp.tools.tokenize.lang.en.TokenSampleStream
- All Implemented Interfaces:
Iterator<TokenSample>
Class which produces an Iterator<TokenSample> from a file of whitespace delimited
tokens. This class uses a number of English-specific heuristics to un-separate tokens which
are typically found together in text.
Tokens are separated by runs of Unicode White_Space, see
StringUtil.splitOnUnicodeWhitespace(CharSequence), independent of the whitespace
mode; leading and trailing whitespace adds no token. A line without a token resets the
quote state, and a token holding a letter or digit of any script is a word rather than
punctuation.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final StringTokens that are not separated from the following word by a space.private static final Stringprivate static final Stringprivate booleanprivate static final Stringprivate final BufferedReaderprivate static final Stringprivate static final Stringprivate Stringprivate static final org.slf4j.Loggerprivate static final Stringprivate static final Stringprivate static final Stringprivate static final StringPunctuation tokens that are separated from the previous token by a space. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate booleancontainsLetterOrDigit(String token) Checks whether a token contains a letter or a decimal digit, by code point.booleanhasNext()next()voidremove()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.Iterator
forEachRemaining
-
Field Details
-
logger
private static final org.slf4j.Logger logger -
LEFT_PAREN
- See Also:
-
LEFT_CURLY
- See Also:
-
RIGHT_PAREN
- See Also:
-
RIGHT_CURLY
- See Also:
-
OPEN_QUOTE
- See Also:
-
DOUBLE_QUOTE
- See Also:
-
DOLLAR
- See Also:
-
HASH
- See Also:
-
APOSTROPHE
- See Also:
-
NEGATION
- See Also:
-
SPACED_PUNCTUATION
Punctuation tokens that are separated from the previous token by a space. -
ATTACHING_TO_NEXT
Tokens that are not separated from the following word by a space. -
in
-
line
-
evenq
private boolean evenq
-
-
Constructor Details
-
TokenSampleStream
- Throws:
IOException
-
-
Method Details
-
hasNext
public boolean hasNext()- Specified by:
hasNextin interfaceIterator<TokenSample>
-
next
- Specified by:
nextin interfaceIterator<TokenSample>
-
remove
public void remove()- Specified by:
removein interfaceIterator<TokenSample>
-
containsLetterOrDigit
Checks whether a token contains a letter or a decimal digit, by code point. A token without one is treated as punctuation.- Parameters:
token- The token.- Returns:
trueif one is present.
-