|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.wallstreetwise.app.jspell.domain.JSpellIndex
public class JSpellIndex
This class manages a hybrid trie/linked list data structure on disk. The data structure contains a trie of phonetic codes, at the leaf node of the trie a linked list is maintained of all the words in that same phonetic grouping. When an attempt to locate a similar word is made the original word is compared against the words in the same phonetic grouping by using an equivalence/similarity scoring algorithm found in the Phonetics class. The first n words with a score greater than a given value are returned to the client.
| Field Summary | |
|---|---|
static int |
baseOffset
Represents the starting offset for phonetic and data nodes in this file. |
static java.lang.String |
defaultCountry
Default country of this dictionary file. |
static java.lang.String |
defaultLanguage
Default language of this dictionary file. |
protected static java.util.HashMap |
mistakeHash
Common spelling mistakes. |
static java.lang.StringBuffer |
version
Identifies JSpell dictionary version. |
| Constructor Summary | |
|---|---|
JSpellIndex()
Constructor for the JSpellIndex class. |
|
JSpellIndex(java.lang.String path,
java.lang.String language,
java.lang.String country)
Constructs a JSpellIndex object. |
|
JSpellIndex(java.lang.String path,
java.lang.String language,
java.lang.String country,
java.lang.String jdxversion)
Constructs a JSpellIndex object. |
|
| Method Summary | |
|---|---|
void |
add(java.lang.String word)
Add a word to the dictionary |
void |
close()
Close access to the JSpellIndex. |
protected boolean |
englishChecks(boolean specialCase,
java.lang.String lowerFirst,
java.lang.String soundexCode,
Suggestions suggestions)
Handle additional English language specific checks. |
protected boolean |
frenchChecks(boolean specialCase,
java.lang.String lowerFirst,
java.lang.String soundexCode,
Suggestions suggestions,
boolean forceUpperCase)
Handle additional French specific spell checker operations. |
int |
getBufferHit()
An int containing the number of buffer 'hits'. |
int |
getBufferMiss()
An int containing the number of buffer 'misses'. |
java.lang.String |
getIndexCountry()
Returns the country of this dictionary file. |
java.lang.String |
getIndexLanguage()
Returns the language of this dictionary file. |
java.lang.String |
getIndexPath()
Returns the location of this dictionary file. |
boolean |
getLocked()
Returns whether or not the JSpellIndex is currently locked, i.e., performing a search or add operation. |
java.lang.StringBuffer |
getVersion()
Returns the version tag of this dictionary file. |
boolean |
isIndexReady()
Returns the status of the JSpellIndex. |
void |
remove(java.lang.String original)
Remove a word from the dictionary |
void |
resetBufferStatistics()
Clear the number of buffer hits and misses. |
boolean |
search(java.lang.String soundex,
java.lang.String original,
java.lang.String[] suggestions)
Overloaded to call search with true, get suggestions. |
boolean |
search(java.lang.String soundex,
java.lang.String original,
java.lang.String[] suggestions,
boolean getSuggestions)
Search for a given word and soundex code and optionally return suggestions. |
boolean |
search(java.lang.String original,
Suggestions suggestions,
boolean specialCase,
boolean forceUpperCase)
Wraps the search(String, String, String[]) method and performs additional search using lower case word if the original word passed begins with an upper case letter. |
void |
setLocked(boolean newValue)
Sets the lock status of the JSpellIndex. |
protected void |
upperCaseSuggestions(java.lang.String original,
boolean specialCase,
boolean forceUpperCase,
java.lang.String[] suggestions)
Convert Strings in Suggestions object to Proper or UPPER CASE depending on parameters. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static java.lang.StringBuffer version
public static final java.lang.String defaultLanguage
public static final java.lang.String defaultCountry
public static int baseOffset
protected static java.util.HashMap mistakeHash
| Constructor Detail |
|---|
public JSpellIndex()
public JSpellIndex(java.lang.String path,
java.lang.String language,
java.lang.String country)
path - location of this dictionary file.language - language of this dictionary file.country - country of this dictionary file.
public JSpellIndex(java.lang.String path,
java.lang.String language,
java.lang.String country,
java.lang.String jdxversion)
path - location of this dictionary file.language - language of this dictionary file.country - country of this dictionary file.jdxversion - Medical, Legal, Other, specify as string, becomes part of filename| Method Detail |
|---|
public int getBufferHit()
public int getBufferMiss()
public void resetBufferStatistics()
public java.lang.StringBuffer getVersion()
public java.lang.String getIndexLanguage()
public java.lang.String getIndexCountry()
public java.lang.String getIndexPath()
public final void close()
public final boolean isIndexReady()
public final boolean getLocked()
public final void setLocked(boolean newValue)
newValue - true or falsepublic final void add(java.lang.String word)
word - a String representing an individual word.public final void remove(java.lang.String original)
original - a String representing an individual word.
public final boolean search(java.lang.String original,
Suggestions suggestions,
boolean specialCase,
boolean forceUpperCase)
throws java.io.IOException
original - a String representing a word.suggestions - a Suggestions object.specialCase - true or false, should word be proper.forceUpperCase - true or false, should word be UPPER CASE.
java.io.IOException - an Exception object.
protected void upperCaseSuggestions(java.lang.String original,
boolean specialCase,
boolean forceUpperCase,
java.lang.String[] suggestions)
original - a String representing the original word.specialCase - true or false, should suggestions be Proper?forceUpperCase - true or false, should suggestions be UPPER CASE?suggestions - a Suggestions object.
protected boolean frenchChecks(boolean specialCase,
java.lang.String lowerFirst,
java.lang.String soundexCode,
Suggestions suggestions,
boolean forceUpperCase)
specialCase - true or false, Proper?lowerFirst - a String, lower case version of word.soundexCode - a String representing the phonetic code of the word.suggestions - a Suggestions object.forceUpperCase - true or false, return suggestions in UPPER CASE.
protected boolean englishChecks(boolean specialCase,
java.lang.String lowerFirst,
java.lang.String soundexCode,
Suggestions suggestions)
throws java.io.IOException
specialCase - true or false, should suggestions be Proper?lowerFirst - a String representing the lower case version of the original word.soundexCode - a String representing a phonetic code.suggestions - a Suggestions object.
java.io.IOException - an Exception object.
public boolean search(java.lang.String soundex,
java.lang.String original,
java.lang.String[] suggestions)
throws java.io.IOException
soundex - a String representing the phonetic code.original - a String representing the original word.suggestions - a Suggestions object.
java.io.IOException - an Exception object.
public boolean search(java.lang.String soundex,
java.lang.String original,
java.lang.String[] suggestions,
boolean getSuggestions)
throws java.io.IOException
getSuggestions - true or false, return suggestions?soundex - a String representing a phonetic code.original - a String representing the original word.suggestions - a Suggestions object.
java.io.IOException - an Exception object.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||