|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Provides spell checking and suggesting services for words. Words are spell
checked against two sets of lists. One set is a set of builtin lists that
are common to the language associated with the locale associated with this
object.
These lists cannot be modified by this API. The second set of lists are
those that
are learned. Words are learned through the use of the spell checking
UI and can be explicitly learned using the method learnWord(java.lang.StringBuffer).
Correction suggestions are determined by looking through the lists of correct words for words that are close to the word in question. A word is considered close to another word if the words are close lexographically or phonetically. The closer a word is to a misspelled word, the higher the word will appear in a list of spelling suggestions for the misspelled word. The builtin lists also track the frequency of the words as they appear in the language. Higher frequency words will be suggested ahead of lower frequency words, sometimes even if the lower frequency word is closer lexographically. If a word has a learned correction then the correction will always appear as the first suggestion.
| Field Summary | ||
|
static int |
OPTION_IGNORE_ACRONYMS
Option to ignore words in all uppercase during spell checking. |
|
static int |
OPTION_IGNORE_ALPHANUMERIC
Option to ignore words containing numbers during spell checking. |
|
static int |
OPTION_IGNORE_CASE
Option to perform case-insensitive spell checking. |
|
static int |
SOURCE_ADDRESS_BOOK
Word Source "Address Book". |
|
static int |
SOURCE_ALL
Word Sources "All". |
|
static int |
SOURCE_LEARNED_WORDS
Word Source "Learned Words". |
|
static int |
SOURCE_NONE
Word Sources "None". |
| Method Summary | ||
|
boolean |
getBooleanOption(int option)
Gets the value of a boolean option. |
|
int |
getSpellingCandidates(StringBuffer word,
StringBuffer suggestions)
Gets suggested spelling candidates for a word. |
|
int |
getSpellingCandidates(StringBuffer word,
Vector suggestions)
Gets suggested spelling candidates for a word. |
|
int |
getWordSources()
Gets the sources that will be used to look up words for spell checking. |
|
boolean |
isCorrect(StringBuffer word)
Checks a word for spelling correctness. |
|
void |
learnCorrection(StringBuffer word,
StringBuffer correction)
Learn a correction to a word. |
|
void |
learnWord(StringBuffer word)
Treat a word as correctly spelled. |
|
void |
setBooleanOption(int option,
boolean value)
Sets the value of a boolean option. |
|
void |
setWordSources(int sources)
Sets the sources that will be used to look up words for spell checking. |
|
void |
unlearnAll()
Unlearns all previously learned words and learned corrections. |
|
void |
unlearnWord(StringBuffer word)
Unlearns a previously-learned word. |
| Field Detail |
public static final int OPTION_IGNORE_ACRONYMS
true.setBooleanOption(int, boolean),
getBooleanOption(int)public static final int OPTION_IGNORE_ALPHANUMERIC
true.setBooleanOption(int, boolean),
getBooleanOption(int)public static final int OPTION_IGNORE_CASE
setBooleanOption(int, boolean),
getBooleanOption(int)public static final int SOURCE_ADDRESS_BOOK
setWordSources(int),
getWordSources()public static final int SOURCE_ALL
The value of this constant is ~0.
setWordSources(int),
getWordSources()public static final int SOURCE_LEARNED_WORDS
setWordSources(int),
getWordSources()public static final int SOURCE_NONE
The value of this constant is zero.
setWordSources(int),
getWordSources()| Method Detail |
public boolean getBooleanOption(int option)
option - the option whose value to get; valid values are any of the
OPTION_
constants defined in this interface.IllegalArgumentException - if the specified option is not valid,
as defined above.setBooleanOption(int, boolean)public int getSpellingCandidates(StringBuffer word, StringBuffer suggestions)
word - a StringBuffer containing the word for which suggestions are
requested;
the entire contents of the buffer will be checked; any leading or
trailing non-word
characters, such as whitespace or symbols, will be considered part of the
word and will
not be trimmed off when performing the check.suggestions - a StringBuffer for holding the suggestions; each
spelling suggestion
will be added to this buffer and suggestions will be separated by the
null character,
'\000'.suggestions.NullPointerException - if any argument is null.getSpellingCandidates(StringBuffer, Vector)public int getSpellingCandidates(StringBuffer word, Vector suggestions)
word - a StringBuffer containing the word for which suggestions are
requested;
the entire contents of the buffer will be checked; any leading or
trailing non-word
characters, such as whitespace or symbols, will be considered part of the
word and will
not be trimmed off when performing the check.suggestions - a container for holding the suggestions; each spelling
suggestion
will be added to this object using Vector.addElement(Object) and
will be an
instance of String.suggestions.NullPointerException - if any argument is null.getSpellingCandidates(StringBuffer, StringBuffer)public int getWordSources()
The default setting is to use all available word sources.
SOURCE_ constants defined in this
interface that
represent the sources that will be used when spell checking.setWordSources(int)public boolean isCorrect(StringBuffer word)
word - a StringBuffer containing the word being spell checked; the
entire
contents of the buffer will be checked; any leading or trailing
non-word characters,
such as whitespace or symbols, will be considered part of the word and
will not be
trimmed off when performing the check.true if the specified word is spelled correctly;
false otherwise.NullPointerException - if any argument is null.public void learnCorrection(StringBuffer word, StringBuffer correction)
Words learned by this method may be unlearned using unlearnWord(java.lang.StringBuffer)
or unlearnAll().
word - a StringBuffer containing the misspelled word whose
correction to learn;
the entire contents of the buffer will be used; any leading or trailing
non-word
characters, such as whitespace or symbols, will be considered part of the
word.correction - a StringBuffer containing the spelling correction to
learn for
word; the entire contents of the buffer will be used; any
leading or trailing
non-word characters, such as whitespace or symbols, will be considered
part of the spelling
correction.isCorrect(java.lang.StringBuffer),
learnWord(java.lang.StringBuffer),
unlearnAll()public void learnWord(StringBuffer word)
If the specified word is already learned then this method does nothing.
Words learned by this method may be unlearned using
unlearnWord(java.lang.StringBuffer) or unlearnAll().
word - a StringBuffer containing the word to be learned;
the entire contents of the buffer will be used; any leading or trailing
non-word
characters, such as whitespace or symbols, will be considered part of the
word and will added to the list of learned words.NullPointerException - if any argument is null.isCorrect(java.lang.StringBuffer),
unlearnWord(java.lang.StringBuffer)
public void setBooleanOption(int option,
boolean value)
option - the option to set; valid values are any of the
OPTION_
constants defined in this interface.value - the value to set for the specified option.IllegalArgumentException - if the specified option is not valid,
as defined above.getBooleanOption(int)public void setWordSources(int sources)
The default setting is to use all available word sources.
The SOURCE_ constants defined in this interface are the
sources recognized
by this method. For convenience, one of SOURCE_ALL or
SOURCE_NONE
can be specified to use all sources or only the built-in source,
respectively.
sources - the set of sources to use when spell checking; this value
is created
by bitwise or-ing the SOURCE_ constants defined in this
interface that
represent the sources to use when spell checking.getWordSources()public void unlearnAll()
public void unlearnWord(StringBuffer word)
If the specified word has never been learned or has already been unlearned then this method does nothing.
This method only unlearns words that were learned by learnWord(java.lang.StringBuffer).
Notably,
it does not unlearn corrections that were learned via
learnCorrection(StringBuffer, StringBuffer). To unlearn
corrections one must use
unlearnAll().
word - a StringBuffer containing the word to be unlearned;
the entire contents of the buffer will be used; any leading or trailing
non-word
characters, such as whitespace or symbols, will be considered part of the
word to unlearn.NullPointerException - if any argument is null.isCorrect(java.lang.StringBuffer),
learnWord(java.lang.StringBuffer),
unlearnAll()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
Copyright 1999-2008 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Copyright 1993-2003 Sun Microsystems, Inc. 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
Copyright 2002-2003 Nokia Corporation All Rights Reserved.
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.