|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectde.fu_berlin.ties.text.TokenCounter
A simple container that keeps track of the tokens in a document. This class
differs from TokenContainer
by not doing
any tokenization itself, relying on external tokenization instead.
Instances of this class are not thread-safe; if you want to share a single instance between different thread, you have to ensure proper synchronization.
Constructor Summary | |
TokenCounter()
Creates a new instance. |
Method Summary | |
void |
add(boolean whitespaceBefore,
String token)
Adds a token to this instance. |
void |
addWhitespace()
Adds whitespace to this instance, setting isWhitespaceAfterLast() to true . |
int |
getCount(String token)
Returns the cardinality of the given token in this container. |
String |
getLast()
Returns the last added token. |
int |
getLastRep()
Returns the repetition of the last added token in the
original text (counting start with 0, as the first occurrence is the
"0th repetition"). |
boolean |
isWhitespaceAfterLast()
Whether there is whitespace after the last added
token. |
boolean |
isWhitespaceBeforeLast()
Whether there is whitespace before the last added
token. |
String |
toString()
Returns a string representation of this object. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public TokenCounter()
Method Detail |
public void add(boolean whitespaceBefore, String token)
whitespaceBefore
- whether there is whitespace before the tokentoken
- the token to addpublic void addWhitespace()
isWhitespaceAfterLast()
to true
.
public int getCount(String token)
token
- the token to check
>= 0
public int getLastRep()
last
added token in the
original text (counting start with 0, as the first occurrence is the
"0th repetition").
public String getLast()
public boolean isWhitespaceAfterLast()
last
added
token.
true
iff there is whitespace after the tokenpublic boolean isWhitespaceBeforeLast()
last
added
token.
true
iff there is whitespace before the tokenpublic String toString()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |