public class TernaryTrieSpellingDictionary extends java.lang.Object implements SpellingDictionary
This class provides the basic methods for a spelling checker dictionary implemented using a ternary trie.
Modifier and Type | Field and Description |
---|---|
protected boolean |
debug
Debugging flag.
|
protected static int |
MAXDIFFS
Maximum edit distance.
|
protected TernaryTrie |
trie
Holds the ternary search trie.
|
protected java.lang.String |
wordListFileName
Word list file which populates dictionary.
|
Constructor and Description |
---|
TernaryTrieSpellingDictionary(java.util.List<java.lang.String> wordsList)
Create TernaryTrieSpellingDictionary from a list containing words.
|
TernaryTrieSpellingDictionary(java.util.Map<java.lang.String,java.lang.String> wordsMap)
Create TernaryTrieSpellingDictionary from a map containing words.
|
TernaryTrieSpellingDictionary(java.util.Set<java.lang.String> wordsSet)
Create TernaryTrieSpellingDictionary from a set containing words.
|
TernaryTrieSpellingDictionary(TaggedStrings wordsList)
Create TernaryTrieSpellingDictionary from a tagged strings list.
|
TernaryTrieSpellingDictionary(TernaryTrie trie)
Create TernaryTrieSpellingDictionary from an existing trie.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addWord(java.lang.String word)
Add a word to the dictionary.
|
boolean |
addWords(java.lang.String[] words)
Add multiple words to the dictionary.
|
void |
clear()
Clear dictionary of all words and metaphone values.
|
java.util.Set<java.lang.String> |
findMostSimilarSet(java.lang.String word) |
java.util.Set<java.lang.String> |
getAllWords()
Retrieves all words in dictionary.
|
java.util.Set<java.lang.String> |
getMoreRelatedWords(java.lang.String word)
Get set of words which almost match given word.
|
int |
getNumberOfWords()
Retrieves number of words in dictionary.
|
java.util.Set<java.lang.String> |
getRelatedWords(java.lang.String word)
Get list of words which almost match given word.
|
boolean |
lookupWord(java.lang.String word)
Lookup word in dictionary.
|
protected TernaryTrie trie
protected java.lang.String wordListFileName
protected boolean debug
protected static final int MAXDIFFS
public TernaryTrieSpellingDictionary(java.util.Map<java.lang.String,java.lang.String> wordsMap)
wordsMap
- Map with words to add to the dictionary.public TernaryTrieSpellingDictionary(java.util.Set<java.lang.String> wordsSet)
wordsSet
- Set with words to add to the dictionary.public TernaryTrieSpellingDictionary(java.util.List<java.lang.String> wordsList)
wordsList
- List with words to add to the dictionary.public TernaryTrieSpellingDictionary(TaggedStrings wordsList)
wordsList
- Tagged strings list with words
to add to the dictionary.public TernaryTrieSpellingDictionary(TernaryTrie trie)
trie
- Trie to use for dictionary.public boolean lookupWord(java.lang.String word)
lookupWord
in interface SpellingDictionary
word
- The word to lookup.Note:
Any processing of the word (conversion to lower case, etc.) should be done before calling this routine.
public boolean addWord(java.lang.String word)
addWord
in interface SpellingDictionary
word
- The word to add to the dictionary.public boolean addWords(java.lang.String[] words)
addWords
in interface SpellingDictionary
words
- The words to add to the dictionary.public java.util.Set<java.lang.String> getRelatedWords(java.lang.String word)
getRelatedWords
in interface SpellingDictionary
word
- The word for which to find similar words.public java.util.Set<java.lang.String> findMostSimilarSet(java.lang.String word)
public java.util.Set<java.lang.String> getAllWords()
getAllWords
in interface SpellingDictionary
public int getNumberOfWords()
getNumberOfWords
in interface SpellingDictionary
public void clear()
clear
in interface SpellingDictionary
public java.util.Set<java.lang.String> getMoreRelatedWords(java.lang.String word)
word
- The word for which to find similar words.