Project Wonder 5.0

er.extensions.components.javascript
Class ERXGoogleSpell

java.lang.Object
  extended by er.extensions.components.javascript.ERXGoogleSpell

public class ERXGoogleSpell
extends java.lang.Object

ERXGoogleSpell provides a simple API to spell checking with Google's web service. This code is based on the work from the blog post http://immike.net/blog/2007/04/07/hacking-google-spell-checker-for-fun-and-profit/.

Author:
mschrag

Nested Class Summary
static class ERXGoogleSpell.Correction
          Correction encapsulates a suggested spelling correction for a word in a string of text.
static class ERXGoogleSpell.CorrectionException
          CorrectionException is thrown if anything fails during the correction process.
 
Constructor Summary
ERXGoogleSpell()
           
 
Method Summary
static java.lang.String correct(java.lang.String text)
          Corrects the spelling of the given text (language = "en", escaping XML).
static java.lang.String correct(java.lang.String text, java.lang.String lang)
          Corrects the spelling of the given text (escaping XML).
static java.lang.String correct(java.lang.String text, java.lang.String lang, java.lang.String hl)
          Corrects the spelling of the given text (escaping XML).
static java.lang.String correct(java.lang.String text, java.lang.String lang, java.lang.String hl, boolean escapeXml)
          Corrects the spelling of the given text.
static void main(java.lang.String[] args)
           
static ERXGoogleSpell.Correction[] suggestions(java.lang.String text)
          Returns possible spelling corrections of the given text (language = "en", escaping XML).
static ERXGoogleSpell.Correction[] suggestions(java.lang.String text, java.lang.String lang)
          Returns possible spelling corrections of the given text (escaping XML).
static ERXGoogleSpell.Correction[] suggestions(java.lang.String text, java.lang.String lang, java.lang.String hl)
          Returns possible spelling corrections of the given text (escaping XML).
static ERXGoogleSpell.Correction[] suggestions(java.lang.String text, java.lang.String lang, java.lang.String hl, boolean escapeXml)
          Returns possible spelling corrections of the given text.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ERXGoogleSpell

public ERXGoogleSpell()
Method Detail

main

public static void main(java.lang.String[] args)
                 throws ERXGoogleSpell.CorrectionException
Throws:
ERXGoogleSpell.CorrectionException

correct

public static java.lang.String correct(java.lang.String text)
                                throws ERXGoogleSpell.CorrectionException
Corrects the spelling of the given text (language = "en", escaping XML).

Parameters:
text - the misspelled text
Returns:
the corrected text
Throws:
ERXGoogleSpell.CorrectionException - if there is a problem correcting the text

correct

public static java.lang.String correct(java.lang.String text,
                                       java.lang.String lang)
                                throws ERXGoogleSpell.CorrectionException
Corrects the spelling of the given text (escaping XML).

Parameters:
text - the misspelled text
lang - the language of the text
Returns:
the corrected text
Throws:
ERXGoogleSpell.CorrectionException - if there is a problem correcting the text

correct

public static java.lang.String correct(java.lang.String text,
                                       java.lang.String lang,
                                       java.lang.String hl)
                                throws ERXGoogleSpell.CorrectionException
Corrects the spelling of the given text (escaping XML).

Parameters:
text - the misspelled text
lang - the language of the text
hl - the human interface language
Returns:
the corrected text
Throws:
ERXGoogleSpell.CorrectionException - if there is a problem correcting the text

correct

public static java.lang.String correct(java.lang.String text,
                                       java.lang.String lang,
                                       java.lang.String hl,
                                       boolean escapeXml)
                                throws ERXGoogleSpell.CorrectionException
Corrects the spelling of the given text.

Parameters:
text - the misspelled text
lang - the language of the text
hl - the human interface language
escapeXml - if true, xml characters in the text will be escaped
Returns:
the corrected text
Throws:
ERXGoogleSpell.CorrectionException - if there is a problem correcting the text

suggestions

public static ERXGoogleSpell.Correction[] suggestions(java.lang.String text)
                                               throws ERXGoogleSpell.CorrectionException
Returns possible spelling corrections of the given text (language = "en", escaping XML).

Parameters:
text - the misspelled text
Returns:
the list of suggested corrections
Throws:
ERXGoogleSpell.CorrectionException - if there is a problem correcting the text

suggestions

public static ERXGoogleSpell.Correction[] suggestions(java.lang.String text,
                                                      java.lang.String lang)
                                               throws ERXGoogleSpell.CorrectionException
Returns possible spelling corrections of the given text (escaping XML).

Parameters:
text - the misspelled text
lang - the language of the text
Returns:
the list of suggested corrections
Throws:
ERXGoogleSpell.CorrectionException - if there is a problem correcting the text

suggestions

public static ERXGoogleSpell.Correction[] suggestions(java.lang.String text,
                                                      java.lang.String lang,
                                                      java.lang.String hl)
                                               throws ERXGoogleSpell.CorrectionException
Returns possible spelling corrections of the given text (escaping XML).

Parameters:
text - the misspelled text
lang - the language of the text
hl - the human interface language
Returns:
the list of suggested corrections
Throws:
ERXGoogleSpell.CorrectionException - if there is a problem correcting the text

suggestions

public static ERXGoogleSpell.Correction[] suggestions(java.lang.String text,
                                                      java.lang.String lang,
                                                      java.lang.String hl,
                                                      boolean escapeXml)
                                               throws ERXGoogleSpell.CorrectionException
Returns possible spelling corrections of the given text.

Parameters:
text - the misspelled text
lang - the language of the text
hl - the human interface language
escapeXml - if true, xml characters in the text will be escaped
Returns:
the list of suggested corrections
Throws:
ERXGoogleSpell.CorrectionException - if there is a problem correcting the text

Last updated: Tue, Feb 21, 2017 • 05:45 PM CET

Copyright © 2002 – 2007 Project Wonder.