public class Speller extends Object
See Jan Daciuk's s_fsa
package.
Modifier and Type | Field and Description |
---|---|
static int |
MAX_WORD_LENGTH
Maximum length of the word to be checked.
|
Constructor and Description |
---|
Speller(Dictionary dictionary) |
Speller(Dictionary dictionary,
int editDistance) |
Modifier and Type | Method and Description |
---|---|
boolean |
convertsCase()
Used to determine whether the dictionary supports case conversions.
|
int |
cuted(int depth,
int wordIndex,
int candIndex)
Calculates cut-off edit distance.
|
int |
ed(int i,
int j,
int wordIndex,
int candIndex)
Calculates edit distance.
|
List<String> |
findReplacements(String w)
Find suggestions by using K.
|
List<String> |
getAllReplacements(String str,
int fromIndex,
int level) |
int |
getCandLen() |
int |
getEffectiveED() |
int |
getFrequency(CharSequence word)
Get the frequency value for a word form.
|
int |
getWordLen() |
boolean |
isCamelCase(String str) |
boolean |
isInDictionary(CharSequence word)
Test whether the word is found in the dictionary.
|
boolean |
isMisspelled(String word)
Checks whether the word is misspelled, by performing a series of checks
according to properties of the dictionary.
|
List<String> |
replaceRunOnWords(String original)
Propose suggestions for misspelled run-on words.
|
public static final int MAX_WORD_LENGTH
public Speller(Dictionary dictionary)
public Speller(Dictionary dictionary, int editDistance)
public boolean isMisspelled(String word)
fsa.dict.speller.ignore-punctuation
is set, then
all non-alphabetic characters are considered to be correctly spelled.
If the flag fsa.dict.speller.ignore-numbers
is set, then all
words containing decimal digits are considered to be correctly spelled.
If the flag fsa.dict.speller.ignore-camel-case
is set, then
all CamelCase words are considered to be correctly spelled.
If the flag fsa.dict.speller.ignore-all-uppercase
is set, then
all alphabetic words composed of only uppercase characters are considered
to be correctly spelled.
Otherwise, the word is checked in the dictionary. If the test fails, and
the dictionary does not perform any case conversions (as set by
fsa.dict.speller.convert-case
flag), then the method returns
false. In case of case conversions, it is checked whether a non-mixed case
word is found in its lowercase version in the dictionary, and for
all-uppercase words, whether the word is found in the dictionary with the
initial uppercase letter.word
- - the word to be checkedpublic boolean isInDictionary(CharSequence word)
word
- the word to be testedpublic int getFrequency(CharSequence word)
word
- the word to be testedpublic List<String> replaceRunOnWords(String original)
original
- The original misspelled word.public List<String> findReplacements(String w)
w
- The original misspelled word.public int ed(int i, int j, int wordIndex, int candIndex)
i
- length of first word (here: misspelled) - 1;j
- length of second word (here: candidate) - 1.wordIndex
- (TODO: javadoc?)candIndex
- (TODO: javadoc?)public int cuted(int depth, int wordIndex, int candIndex)
depth
- current length of candidates.wordIndex
- (TODO: javadoc?)candIndex
- (TODO: javadoc?)public boolean isCamelCase(String str)
str
- The string to check.public boolean convertsCase()
public List<String> getAllReplacements(String str, int fromIndex, int level)
str
- The string to find the replacements for.fromIndex
- The index from which replacements are found.level
- The recursion level. The search stops if level is > MAX_RECURSION_LEVEL.public final int getWordLen()
public final int getCandLen()
public final int getEffectiveED()
Copyright © 2016. All rights reserved.