/** * Returns the index of the start of the current word in the text * * @return index in string of the start of the current word. * @throws WordNotFoundException current word has not yet been set. */ public int getCurrentWordPosition() { if (currentWord == null) { throw new WordNotFoundException("No Words in current String"); } return currentWord.getStart(); }
/** * Returns the end of the current word in the text * * @return index in string of the end of the current word. * @throws WordNotFoundException current word has not yet been set. */ public int getCurrentWordEnd() { if (currentWord == null) { throw new WordNotFoundException("No Words in current String"); } return currentWord.getEnd(); }
public String spellCorrect(String text) { StringWordTokenizer swt = new StringWordTokenizer(text); spellChecker.checkSpelling(swt); return swt.getContext(); }
/** * Creates a new default AbstractWordFinder object. */ public AbstractWordFinder() { text = ""; setup(); } //~ Methods ...............................................................
/** * Returns the current word in the iteration . * * @return the current word. * @throws WordNotFoundException current word has not yet been set. */ public Word current() { if (currentWord == null) { throw new WordNotFoundException("No Words in current String"); } return currentWord; }
/** * Returns true if there are more words that can be processed in the string * * @return true if there are further words in the text. */ public boolean hasMoreWords() { return finder.hasNext(); }
/** * returns true if the current word is at the start of a sentence * * @return true if the current word starts a sentence. * @throws WordNotFoundException current word has not yet been set. */ public boolean isNewSentence() { return finder.startsSentence(); } }
/** * Constructs the SpellChecker. The default threshold is used * * @param dictionary The dictionary used for looking up words. */ public SpellChecker(SpellDictionary dictionary) { this(); addDictionary(dictionary); }
/** * Initializes this word finder */ protected void init() { // sentenceIterator = BreakIterator.getSentenceInstance(); // sentenceIterator.setText(text); super.init(); inComment = false; } }
/** * Creates a new StringWordTokenizer object. * @param s the string to work on * @param finder the custom WordFinder to use in tokenizing. Note * that the string to tokenize will be encapsulated within the WordFinder. */ public StringWordTokenizer(String s, WordFinder finder) { super(finder); finder.setText(s); }
/** * * @deprecated use getContext() instead as per the WordTokenizer * interface specification. * @return the final text. */ public String getFinalText() { return getContext(); }
/** * Creates a new Word object. * * @param text the String representing the word. * @param start the start index of the word. */ public Word(String text, int start) { this.text = text; this.start = start; setEnd(); }
/** * Activates a cache with the maximum number of entries set to 300 */ public void setCache() { setCache(300); }
/** * Checks the text string. * <p> * Returns the corrected string. * * @param text The text that need to be spelled checked * @return The text after spell checking * @deprecated use checkSpelling(WordTokenizer) */ public String checkString(String text) { StringWordTokenizer tokens = new StringWordTokenizer(text); checkSpelling(tokens); return tokens.getContext(); }
/** * Creates a new AbstractWordFinder object. * * @param inText the String to iterate through. */ public AbstractWordFinder(String inText) { text = inText; setup(); }
/** * @return true if the current word starts a new sentence. * @throws WordNotFoundException current word has not yet been set. */ public boolean startsSentence() { if (currentWord == null) { throw new WordNotFoundException("No Words in current String"); } return startsSentence; }
/** * Defines the text to search. * @param newText The text to be analyzed */ public void setText(String newText) { text = newText; setup(); }