How can I do spell checking and/or spell correction in a Java application?
Generally, The Jazzy API is used to perform Spelling Correction for Given String in Java. It can be downloaded in the below link. Download Jazzy Core 0.5.2 Jar and Add downloaded jar file to your eclipse Project.
The SpellCheckerApplication is a class, which contain the main method. Eventually Its our entry point of Java Spelling Checker application.
Given an array of strings str [] and a string key, the task is to check if the spelling of the key is correct or not. If found to be true, then print “YES”. Otherwise, print the suggested correct spellings. The string “geek” not present in the array of strings.
Create a SpellingDialog (AWT) or JSpellCheckDlg (Swing) object and pass the StringWordParser to the constructor Call the SpellingDialog's or JSpellCheckDlg's setVisible method to being the spell check operation.
Google's Spell Checker http://code.google.com/p/google-api-spelling-java/
SpellChecker checker = new SpellChecker();
SpellResponse spellResponse = checker.check( "helloo worlrd" );
for( SpellCorrection sc : spellResponse.getCorrections() )
System.out.println( sc.getValue() );
It's much like when you use Gmail or Google services (like translate.google.com or search) that gives you alternate suggestion if you have a typo.
What happens in the background?
The SpellChecker class transforms the request into XML and sends it to the Google's spell checker service. The response is also in XML, which is then deserialized into simple POJOs.
The request to the first example above looks like:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <spellrequest textalreadyclipped="0" ignoredigits="1" ignoreallcaps="1" ignoredups="0"> <text>helloo worlrd</text> </spellrequest>
And the response XML looks like:
<?xml version="1.0" encoding="UTF-8"?> <spellresult error="0" clipped="0" charschecked="13"> <c o="0" l="6" s="1">hello Helli hell hallo hullo</c> <c o="7" l="6" s="1">world whorled wold warlord would</c> </spellresult>
Haven't tried though.
UPDATE:
Google might have started charging for this. I do not have time to code to check this. Someone can confirm. As far as Google is concerned, it seems that they have deprecated the old API for new and paid one.
Refer: Google Translate API FAQ
What happened to earlier free versions of Translate API?
Google Translate API v1 is no longer available as of December 1, 2011 and has been replaced by Google Translate API v2. Google Translate API v1 was officially deprecated on May 26, 2011. The decision to deprecate the API and replace it with the paid service was made due to the substantial economic burden caused by extensive abuse.
You can use JOrtho. I have used it earlier in one of the swing app.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With