|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface SpellCheckEngine
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 SpellCheckEngine.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. |
|
Locale |
getLocale()
Gets the locale whose language is being used by this object for spell checking. |
|
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 |
---|
static final int OPTION_IGNORE_CASE
SpellCheckEngine.setBooleanOption(int, boolean)
,
SpellCheckEngine.getBooleanOption(int)
,
Constant Field Valuesstatic final int OPTION_IGNORE_ACRONYMS
true
.
SpellCheckEngine.setBooleanOption(int, boolean)
,
SpellCheckEngine.getBooleanOption(int)
,
Constant Field Valuesstatic final int OPTION_IGNORE_ALPHANUMERIC
true
.
SpellCheckEngine.setBooleanOption(int, boolean)
,
SpellCheckEngine.getBooleanOption(int)
,
Constant Field Valuesstatic final int SOURCE_NONE
The value of this constant is zero.
SpellCheckEngine.setWordSources(int)
,
SpellCheckEngine.getWordSources()
,
Constant Field Valuesstatic final int SOURCE_ADDRESS_BOOK
SpellCheckEngine.setWordSources(int)
,
SpellCheckEngine.getWordSources()
,
Constant Field Valuesstatic final int SOURCE_LEARNED_WORDS
SpellCheckEngine.setWordSources(int)
,
SpellCheckEngine.getWordSources()
,
Constant Field Valuesstatic final int SOURCE_ALL
The value of this constant is ~0
.
SpellCheckEngine.setWordSources(int)
,
SpellCheckEngine.getWordSources()
,
Constant Field ValuesMethod Detail |
---|
Locale getLocale()
null
.void setWordSources(int sources)
SpellCheckEngine.isCorrect(java.lang.StringBuffer)
and for suggesting corrections
via SpellCheckEngine.getSpellingCandidates(java.lang.StringBuffer, java.util.Vector)
.
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 SpellCheckEngine.SOURCE_ALL
or
SpellCheckEngine.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.SpellCheckEngine.getWordSources()
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.SpellCheckEngine.setWordSources(int)
void setBooleanOption(int option, boolean value)
option
- the option to set; valid values are any of the
OPTION_
constants defined in this interface. Setting options constants
affects both SpellCheckEngine.isCorrect(java.lang.StringBuffer)
and SpellCheckEngine.getSpellingCandidates(java.lang.StringBuffer, java.util.Vector)
methods. If the current system locale is not supported by the engine
then nothing is set.value
- the value to set for the specified option.
IllegalArgumentException
- if the specified option is not valid,
as defined above.SpellCheckEngine.getBooleanOption(int)
boolean getBooleanOption(int option)
option
- the option whose value to get; valid values are any of the
OPTION_
constants defined in this interface.
false
if the current
system locale is not supported by the engine.
IllegalArgumentException
- if the specified option is not valid,
as defined above.SpellCheckEngine.setBooleanOption(int, boolean)
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 or null;
false
otherwise. In addition, if the current system locale
is not supported by the engine it returns false
.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
or -1 if
the current system locale is not supported by the engine.
NullPointerException
- if any argument is null.SpellCheckEngine.getSpellingCandidates(StringBuffer, StringBuffer)
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
or -1 if the
current system locale is not supported by the engine.
NullPointerException
- if any argument is null.SpellCheckEngine.getSpellingCandidates(StringBuffer, Vector)
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
SpellCheckEngine.unlearnWord(java.lang.StringBuffer)
or SpellCheckEngine.unlearnAll()
. Note: Words are learned
regardless of what SOURCE_ * constants may have been set on the engine.
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.SpellCheckEngine.isCorrect(java.lang.StringBuffer)
,
SpellCheckEngine.unlearnWord(java.lang.StringBuffer)
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 SpellCheckEngine.learnWord(java.lang.StringBuffer)
.
Notably,
it does not unlearn corrections that were learned via
SpellCheckEngine.learnCorrection(StringBuffer, StringBuffer)
. To unlearn
corrections one must use
SpellCheckEngine.unlearnAll()
. Note: Words are unlearned regardless
of what SOURCE_ * constants may have been set on the engine.
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.SpellCheckEngine.isCorrect(java.lang.StringBuffer)
,
SpellCheckEngine.learnWord(java.lang.StringBuffer)
,
SpellCheckEngine.unlearnAll()
void learnCorrection(StringBuffer word, StringBuffer correction)
SpellCheckEngine.getSpellingCandidates(java.lang.StringBuffer, java.util.Vector)
is invoked with the exact same word for which the correction was learned.
If it is desired for the correction to appear as a spelling candidate for words that are
close to the correction, learn the word via SpellCheckEngine.learnWord(java.lang.StringBuffer)
. Note: corrections are
learned regardless of what SOURCE_ * constants may have been set on the engine.
Words learned by this method may be unlearned using SpellCheckEngine.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.
NullPointerException
- if any argument is nullSpellCheckEngine.isCorrect(java.lang.StringBuffer)
,
SpellCheckEngine.learnWord(java.lang.StringBuffer)
,
SpellCheckEngine.unlearnAll()
void unlearnAll()
SpellCheckEngine.isCorrect(java.lang.StringBuffer)
,
SpellCheckEngine.learnCorrection(java.lang.StringBuffer, java.lang.StringBuffer)
,
SpellCheckEngine.learnWord(java.lang.StringBuffer)
,
SpellCheckEngine.unlearnWord(java.lang.StringBuffer)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal