public class BasicWordIter extends Object implements WordIter, Cloneable
Created: Dec 13, 2004
| Modifier and Type | Field and Description |
|---|---|
protected int |
maxWordPos
Word position of the last token
|
protected String |
text
The original text to which the tokens refer
|
protected Token[] |
tokens
Array of tokens, holding words from the current chunk
|
protected int |
tokNum
Current token this iterator is pointed at
|
protected int |
wordPos
Word position of the curren token
|
FIELD_END, FIELD_START, TERM_END, TERM_END_PLUS, TERM_START| Modifier | Constructor and Description |
|---|---|
protected |
BasicWordIter()
Do-nothing constructor - should only be used by derived classes
that perform their own initialization.
|
|
BasicWordIter(String text,
TokenStream stream)
Construct the iterator and read in tokens from the given stream.
|
| Modifier and Type | Method and Description |
|---|---|
Object |
clone()
Make an exact, independent, copy of this iterator
|
MarkPos |
getPos(int startOrEnd)
Retrieve the start or end of the current position.
|
void |
getPos(MarkPos pos,
int startOrEnd)
Replace the position within a MarkPos created by
WordIter.getPos(int)
using the iterator's current position. |
boolean |
next(boolean force)
Advance to the next word.
|
boolean |
prev(boolean force)
Back up to the previous word.
|
void |
seekFirst(int targetPos,
boolean force)
Reposition the iterator at the first word whose position is
greater than or equal to 'wordPos'.
|
void |
seekLast(int targetPos,
boolean force)
Reposition the iterator at the last word whose position is
less than or equal to 'wordPos'.
|
String |
term()
Retrieve the text of the term at the current position
|
protected String text
protected Token[] tokens
protected int tokNum
protected int wordPos
protected int maxWordPos
public BasicWordIter(String text,
TokenStream stream)
throws IOException
text - text represented by the tokensstream - stream of tokens from the textIOException - If something goes wrong reading from 'stream'protected BasicWordIter()
public Object clone()
WordIterpublic boolean next(boolean force)
WordIterpublic boolean prev(boolean force)
WordIterpublic void seekFirst(int targetPos,
boolean force)
WordIterpublic void seekLast(int targetPos,
boolean force)
WordIterpublic MarkPos getPos(int startOrEnd)
WordItergetPos in interface WordIterstartOrEnd - FIELD_START for the very start of the field;
TERM_START for the first character of the word;
TERM_END for the last character of the word;
TERM_END_PLUS for the last character plus any trailing
punctuation and/or spaces;
FIELD_END for the very last end of the field.public void getPos(MarkPos pos, int startOrEnd)
WordIterWordIter.getPos(int)
using the iterator's current position.getPos in interface WordIterstartOrEnd - FIELD_START for the very start of the field;
TERM_START for the first character of the word;
TERM_END for the last character of the word;
TERM_END_PLUS for the last character plus any trailing
punctuation and/or spaces;
FIELD_END for the very last end of the field.