com.jspell.domain
Class JSpellIndex

java.lang.Object
  extended by com.jspell.domain.JSpellIndex

public class JSpellIndex
extends java.lang.Object

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
 int trialDays
           
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.
 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 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

version

public static java.lang.StringBuffer version
Identifies JSpell dictionary version.


trialDays

public final int trialDays
See Also:
Constant Field Values
Constructor Detail

JSpellIndex

public JSpellIndex()
Constructor for the JSpellIndex class.


JSpellIndex

public JSpellIndex(java.lang.String path,
                   java.lang.String language,
                   java.lang.String country)
Constructs a JSpellIndex object.

Parameters:
path - location of this dictionary file.
language - language of this dictionary file.
country - country of this dictionary file.

JSpellIndex

public JSpellIndex(java.lang.String path,
                   java.lang.String language,
                   java.lang.String country,
                   java.lang.String jdxversion)
Constructs a JSpellIndex object.

Parameters:
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

getBufferHit

public int getBufferHit()
An int containing the number of buffer 'hits'.

Returns:
The number of buffer 'hits'.

getBufferMiss

public int getBufferMiss()
An int containing the number of buffer 'misses'.

Returns:
The number of buffer 'misses'.

resetBufferStatistics

public void resetBufferStatistics()
Clear the number of buffer hits and misses.


getIndexLanguage

public java.lang.String getIndexLanguage()
Returns the language of this dictionary file.

Returns:
a String.

getIndexCountry

public java.lang.String getIndexCountry()
Returns the country of this dictionary file.

Returns:
a String.

getIndexPath

public java.lang.String getIndexPath()
Returns the location of this dictionary file.

Returns:
a String.

close

public final void close()
Close access to the JSpellIndex.


isIndexReady

public final boolean isIndexReady()
Returns the status of the JSpellIndex.

Returns:
true or false

add

public final void add(java.lang.String word)
Add a word to the dictionary

Parameters:
word - a String representing an individual word.

remove

public final void remove(java.lang.String original)
Remove a word from the dictionary

Parameters:
original - a String representing an individual word.

search

public final boolean search(java.lang.String original,
                            Suggestions suggestions,
                            boolean specialCase,
                            boolean forceUpperCase)
                     throws java.io.IOException
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. This is inexpensive, since, the previous search with the same phonetic code should still be buffered.

Parameters:
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.
Returns:
true or false, was word found.
Throws:
java.io.IOException - an Exception object.

search

public boolean search(java.lang.String soundex,
                      java.lang.String original,
                      java.lang.String[] suggestions)
               throws java.io.IOException
Overloaded to call search with true, get suggestions.

Parameters:
soundex - a String representing the phonetic code.
original - a String representing the original word.
suggestions - a Suggestions object.
Returns:
true or false
Throws:
java.io.IOException - an Exception object.

search

public boolean search(java.lang.String soundex,
                      java.lang.String original,
                      java.lang.String[] suggestions,
                      boolean getSuggestions)
               throws java.io.IOException
Search for a given word and soundex code and optionally return suggestions.

Parameters:
getSuggestions - true or false, return suggestions?
soundex - a String representing a phonetic code.
original - a String representing the original word.
suggestions - a Suggestions object.
Returns:
true or false
Throws:
java.io.IOException - an Exception object.


JSpell SDK - Spell Checker for the Java ™ Platform
Copyright © 2009 Page Scholar Inc, All Rights Reserved - http://www.jspell.com