com.swabunga.spell.event
public interface WordTokenizer
An interface for objects which take a text-based media as input, and iterate through the words in the text stored in that media. Examples of such media could be Strings, Documents, Files, TextComponents etc.
When the object is instantiated, and before the first call to next()
is made,
the following methods should throw a WordNotFoundException
:
getCurrentWordEnd()
, getCurrentWordPosition()
,
isNewSentence()
and replaceWord()
.
A call to next()
when hasMoreWords()
returns false
should throw a WordNotFoundException
.
Method Summary | |
---|---|
String | getContext()
Returns the context text that is being tokenized (should include any
changes that have been made). |
int | getCurrentWordCount()
Returns the number of word tokens that have been processed thus far |
int | getCurrentWordEnd()
Returns an index representing the end location of the current word in the text. |
int | getCurrentWordPosition()
Returns an index representing the start location of the current word in the text. |
boolean | hasMoreWords()
Indicates if there are more words left |
boolean | isNewSentence()
Returns true if the current word is at the start of a sentence |
String | nextWord()
This returns the next word in the iteration. |
void | replaceWord(String newWord)
Replaces the current word token
When a word is replaced care should be taken that the WordTokenizer
repositions itself such that the words that were added aren't rechecked.
|
Returns: the text being searched.
Returns: the number of words found so far.
Returns: index of the end of the current word in the text.
Throws: WordNotFoundException current word has not yet been set.
Returns: index of the start of the current word in the text.
Throws: WordNotFoundException current word has not yet been set.
Returns: true if more words can be found in the text.
Returns: true if the current word starts a sentence.
Throws: WordNotFoundException current word has not yet been set.
Returns: the next word in the iteration.
Throws: WordNotFoundException search string contains no more words.
Parameters: newWord the string which should replace the current word.
Throws: WordNotFoundException current word has not yet been set.