Non-GUI Spell Checker

The RapidSpellChecker Bean component is of particular use in non-GUI scenarios such as the

web. Below is a very simple excerpt of how this component can be used.

Code Example

.........

RapidSpellChecker c = new RapidSpellChecker();

BadWord badWord;

Enumeration suggestions;

//check some text.

c.check(“This is sume text.”);

//iterate through all bad words in the text.

while((badWord = c.nextBadWord())!=null){

System.out.println(badWord.getWord() + “- is not spelt correctly.

Suggestions:”);

try{

//get suggestions for the current bad word.

suggestions = c.findSuggestions().elements();

//display all suggestions.

while(suggestions.hasMoreElements()) {

System.out.println(suggestions.nextElement());

}

//change the bad word in the text with “replacement”.

c.changeBadWord(“replacement”);

} catch (NoCurrentBadWordException e){

System.err.println(e);

}

}

System.out.println(c.getAmendedText());

.........