Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.util
Class SpellChecker

java.lang.Object
  extended by com.jivesoftware.util.SpellChecker

public class SpellChecker
extends java.lang.Object

The Spell checker is used to create spell session objects to iteratively fix spelling mistakes in text. Multiple languages are supported, with American English, British English, French, French Canadian, German, Italian and Spanish supported out of the box. Additional dictionaries can be purchases and used by simply putting them in jiveHome/spelling directory and calling reloadDictionaries().

The format to specify the language to use as parameters to methods in this class is the ISO code for the language (http://www-old.ics.uci.edu/pub/ietf/http/related/iso639.txt). The language may also contain a 2 digit country code (http://www.chemie.fu-berlin.de/diverse/doc/ISO_3166.html) to specify country specific languages if they are supported. Example: 'en', 'en_US', 'en_GB'.


Method Summary
static void addCustomWord(java.lang.String word)
          Adds a word to the global custom dictionary (the custom dictionary that is used for spell checking across all languages).
static void addCustomWord(java.lang.String word, java.lang.String language)
          Adds a word to the custom dictionary for the specified language.
static SpellSession createSession(java.lang.String text)
          Creates a new SpellSession to spell check a text block.
static SpellSession createSession(java.lang.String text, java.util.List ignoreWords)
          Creates a new SpellSession to spell check a text block.
static SpellSession createSession(java.lang.String text, java.lang.String language)
          Creates a new SpellSession to spell check a text block.
static SpellSession createSession(java.lang.String text, java.lang.String language, java.util.List ignoreWords)
          Creates a new SpellSession to spell check a text block.
static void deleteCustomWord(java.lang.String word)
          Deletes a word from the global custom dictionary (the custom dictionary that is used for spell checking across all languages).
static void deleteCustomWord(java.lang.String word, java.lang.String language)
          Deletes a word from the custom dictionary.
static java.util.List getAvailableLanguages()
          Return the list of languages that are available to use for spell checking.
protected static com.wintertree.ssce.FileTextLexicon getCustomLexicon(java.lang.String language)
          Returns the custom FileTextLexicon (dictionary) for the specified language.
static java.lang.String[] getCustomWords()
          Returns an array of all the words in the global custom dictionary (the custom dictionary that is used for spell checking across all languages).
static java.lang.String[] getCustomWords(java.lang.String language)
          Returns an array of all the words in the custom dictionary for the specified language.
static com.wintertree.ssce.Lexicon[] getLexicons(java.lang.String language)
          Returns the array of Lexicons (dictionaries) for the specified language.
static void reloadDictionaries()
          Re-initializes the spell-checking dictionaries.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createSession

public static SpellSession createSession(java.lang.String text)
Creates a new SpellSession to spell check a text block. The language that will be used is the globally defined default spelling language.

Parameters:
text - the text to spell check.
Returns:
a new SpellSession object for the text using the globally defined default spelling language.

createSession

public static SpellSession createSession(java.lang.String text,
                                         java.lang.String language)
Creates a new SpellSession to spell check a text block. The language specified will be used to select the proper dictionary to be used. If no dictionaries for the specified language are found then the globally defined default spelling language will be used.

Parameters:
text - the text to spell check.
language - the language to use.
Returns:
a new SpellSession object for the text using the specified language if found or the globally defined default spelling language if not.

createSession

public static SpellSession createSession(java.lang.String text,
                                         java.util.List ignoreWords)
Creates a new SpellSession to spell check a text block.

Parameters:
text - the text to spell check.
ignoreWords - a list of words to ignore while spell checking
Returns:
a new SpellSession object for the text.

createSession

public static SpellSession createSession(java.lang.String text,
                                         java.lang.String language,
                                         java.util.List ignoreWords)
Creates a new SpellSession to spell check a text block. The language specified will be used to select the proper dictionary to be used. If no dictionaries for the specified language are found then the globally defined default spelling language will be used.

Parameters:
text - the text to spell check.
language - the language to use.
ignoreWords - a list of words to ignore while spell checking
Returns:
a new SpellSession object for the text.

getAvailableLanguages

public static java.util.List getAvailableLanguages()
Return the list of languages that are available to use for spell checking.

Returns:
a list of languages that are available to use for spell checking.

getCustomWords

public static java.lang.String[] getCustomWords()
Returns an array of all the words in the global custom dictionary (the custom dictionary that is used for spell checking across all languages).

The custom dictionary contains words that don't appear in the normal dictionaries, but that should still be considered as being spelled correctly. Examples include company names, technical terms, or slang.

Returns:
an array of the words in the global custom dictionary.

getCustomWords

public static java.lang.String[] getCustomWords(java.lang.String language)
Returns an array of all the words in the custom dictionary for the specified language. The custom dictionary contains words that don't appear in the normal dictionaries, but that should still be considered as being spelled correctly. Examples include company names, technical terms, or slang.

The language specified will be used to select the custom dictionary to be used. If a custom dictionary for the specified language is not found then this method will return null.

Parameters:
language - the language to retrieve the custom words for
Returns:
an array of the words in the custom dictionary for the specified language.

addCustomWord

public static void addCustomWord(java.lang.String word)
Adds a word to the global custom dictionary (the custom dictionary that is used for spell checking across all languages).

The custom dictionary contains words that don't appear in the normal dictionaries, but that should still be considered as being spelled correctly. Examples include company names, technical terms, or slang.

Parameters:
word - the word to add to the global custom dictionary.

addCustomWord

public static void addCustomWord(java.lang.String word,
                                 java.lang.String language)
Adds a word to the custom dictionary for the specified language. The custom dictionary contains words that don't appear in the normal dictionaries, but that should still be considered as being spelled correctly. Examples include company names, technical terms, or slang.

The language specified will be used to select the custom dictionary to be used. If a custom dictionary for the specified language is not found then this method is a noop.

Parameters:
word - the word to add to the custom dictionary.
language - the language to add the custom word to

deleteCustomWord

public static void deleteCustomWord(java.lang.String word)
Deletes a word from the global custom dictionary (the custom dictionary that is used for spell checking across all languages).

The custom dictionary contains words that don't appear in the normal dictionaries, but that should still be considered as being spelled correctly. Examples include company names, technical terms, or slang.

Parameters:
word - the word to delete from the global custom dictionary.

deleteCustomWord

public static void deleteCustomWord(java.lang.String word,
                                    java.lang.String language)
Deletes a word from the custom dictionary. The custom dictionary contains words that don't appear in the normal dictionaries, but that should still be considered as being spelled correctly. Examples include company names, technical terms, or slang.

The language specified will be used to select the custom dictionary to be used. If a custom dictionary for the specified language is not found then this method is a noop.

Parameters:
word - the word to delete from the custom dictionary.
language - the language to delete the custom word from

reloadDictionaries

public static void reloadDictionaries()
Re-initializes the spell-checking dictionaries.


getLexicons

public static com.wintertree.ssce.Lexicon[] getLexicons(java.lang.String language)
Returns the array of Lexicons (dictionaries) for the specified language. If the language is not found then null will be returned.

Returns:
the array of Lexicons being used for spell checking.

getCustomLexicon

protected static com.wintertree.ssce.FileTextLexicon getCustomLexicon(java.lang.String language)
Returns the custom FileTextLexicon (dictionary) for the specified language. If the language is not found then null will be returned.

Returns:
the custom FileTextLexicon (dictionary) for the specified language.

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.