Fido Alpha 3.2

fido.db
Class DictionaryTable

java.lang.Object
  |
  +--fido.db.DictionaryTable

public class DictionaryTable
extends java.lang.Object

The dictionary is a simple map that takes a String input, representing a word in the sentence, and returns a collection of zero to many WordSenses. Each WordSense is a distinct definition of a word. Each word sense also contains a grammar string that is used to connect words in the user input.

By default, the dictionary contains two special words. These words cannot be matched by words of the same name in a sentence because these words are stored as all uppercase and the Word Separation module converts all words from the sentence to lower case.

  1. LEFT-WALL - This word is the left most word of a sentence. It provides grammar links to find the verb in a sentence.
  2. UNKNOWN-WORD - This word is the default if no other word matches the String from the input sentence. This allows the grammar parser to include this word in the sentence and let the semantic processing determine the real meaning.

See Also:
ObjectTable, WordSense, WordSeparation

Constructor Summary
DictionaryTable()
          Creates a new instance of DictionaryTable
 
Method Summary
 int add(java.lang.String word, java.lang.String grammarString, int objectId)
          Adds a new word sense to a word.
 boolean contains(java.lang.String word)
          Tests for the existance of a word in the dictionary.
 void delete(java.lang.String word, int row)
          Removes a word sense of a word specified by the row number.
 void deleteReferenceToObject(java.sql.Statement stmt, java.lang.String objectId)
          Scans all of the dictionary words for a reference to the class and removes the reference.
 int hashCode(java.lang.String word, java.lang.String row)
          Creates a hash value for a given row.
 java.util.Collection list()
          Returns an array of Strings containing all of the words in the dictionary.
 java.util.Collection lookupWord(java.lang.String word)
          Retrieves a specified entry from the dictionary specified by word.
 void modify(java.lang.String word, int row, java.lang.String grammarString, int objectId)
          Replaces a word sense of a word specified by the row number.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DictionaryTable

public DictionaryTable()
Creates a new instance of DictionaryTable

Method Detail

list

public java.util.Collection list()
                          throws FidoDatabaseException
Returns an array of Strings containing all of the words in the dictionary. Each word may or may not contain word senses. The list of words are in alphabetical order.

Returns:
array of all words
FidoDatabaseException

contains

public boolean contains(java.lang.String word)
                 throws FidoDatabaseException
Tests for the existance of a word in the dictionary.

Returns:
true if the string is in the dictionary, even if it has no senses.
FidoDatabaseException

add

public int add(java.lang.String word,
               java.lang.String grammarString,
               int objectId)
        throws FidoDatabaseException,
               GrammarLinkNotFoundException,
               GrammarParseException,
               ObjectNotFoundException
Adds a new word sense to a word. If the word does not exists in the Dictionary, a new word is created. After adding the word sense, the Dictionary is stored in the database. If the representedObject entry of the WordSense is not null, then a link between the object in the ObjectTable and this word is created with the system link type Word.

Parameters:
word - word to add the word sense to
Returns:
row number of the new word sense within the word
Throws:
java.sql.SQLException - thrown if there is a Input / Output error saving the Dictionary.
LinkTypeNotFoundException - thrown if the LinkTypeList does not contain the system link Word
FidoDatabaseException
GrammarLinkNotFoundException
GrammarParseException
ObjectNotFoundException

modify

public void modify(java.lang.String word,
                   int row,
                   java.lang.String grammarString,
                   int objectId)
            throws FidoDatabaseException,
                   GrammarLinkNotFoundException,
                   GrammarParseException,
                   ObjectNotFoundException,
                   WordNotFoundException
Replaces a word sense of a word specified by the row number.

Parameters:
word - word to replace the word sense in
row - used to specify which word sense to replace.
Throws:
FidoDatabaseException - thrown if there is a Input / Output error saving the Dictionary.
WordNotFoundException - word parameter does not exists in the Dictionary
GrammarLinkNotFoundException
GrammarParseException
ObjectNotFoundException

delete

public void delete(java.lang.String word,
                   int row)
            throws FidoDatabaseException
Removes a word sense of a word specified by the row number.

Parameters:
word - word to remove the word sense from
row - used to specify which word sense to remove
Throws:
FidoDatabaseException - thrown if there is a Input / Output error saving the Dictionary.
WordNotFoundException - word parameter does not exists in the Dictionary
ObjectNotFoundException - the object in the WordSense was not found in the ObjectTable
LinkTypetNotFoundException - the system link type Word was not found in the LinkTypeList

lookupWord

public java.util.Collection lookupWord(java.lang.String word)
                                throws FidoDatabaseException,
                                       GrammarParseException,
                                       GrammarLinkNotFoundException
Retrieves a specified entry from the dictionary specified by word.

Returns:
a Vector containing all of the WordSenses for the word. If the word is not found, an empty Vector is returned.
FidoDatabaseException
GrammarParseException
GrammarLinkNotFoundException

deleteReferenceToObject

public void deleteReferenceToObject(java.sql.Statement stmt,
                                    java.lang.String objectId)
                             throws java.sql.SQLException
Scans all of the dictionary words for a reference to the class and removes the reference.

Throws:
FidoDatabaseException - thrown if there is a Input / Output error saving the Dictionary.
java.sql.SQLException

hashCode

public int hashCode(java.lang.String word,
                    java.lang.String row)
             throws FidoDatabaseException,
                    WordNotFoundException
Creates a hash value for a given row. This is a unique integer value that represents all of the columns for that row. This is used by data entry servlets to ensure the row was not updated between the time the row data was downloaded, and the time the user sent the update.

Returns:
A unique integer representing the data for the row.
Throws:
FidoDatabaseException - Thrown if the database had an error.
WordNotFoundException - Thrown if the parameters did not specify a row in the table.

Fido Alpha 3.2