Fido Alpha 3.2

fido.grammar
Class Grammar

java.lang.Object
  |
  +--fido.grammar.Grammar

public class Grammar
extends java.lang.Object

The Fido system uses a grammatical system called link grammar to identify relationships between words in the user command. The command is defined as a set of words, which is the terminal symbols of the grammar, each of which has a linking requirement. A sequence of words is defined as a successful sentence if:

The linking requirements are passed into the module via Word Senses of a Word Package. Each Word Sense in the Word Package contains a grammar string, the linking requirement, and a pointer to the node in the hierarchy. Each Grammar String is a list of connectors joined by boolean operators and and or. Also some connectors can have multiple connectors connect to it, and some connectors can be optional.

See Grammar String Concepts for a description of Grammar Strings and how they are used to link words.

A typical usage of Grammar would be to create an instance, which will start a new sentence with no threads. Use insertWord() method to incrementally add words to the sentence. When complete, call finalizeSentece() to ensure the sentence is valid and return a Vector containing the links of the sentence.

See Also:
WordSense, WordPackage

Constructor Summary
Grammar()
          Creates a new Grammar class with an empty thread stack.
 
Method Summary
 java.util.Vector finalizeSentence()
          Ensures all threads are valid by checking to see there are no open links that have not been satisfied.
 java.util.Vector getThreads()
          This method returns all of the sentence threads.
 void insertWord(WordPackage wordPack)
          Inserts a new word string into the current grammar.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Grammar

public Grammar()
Creates a new Grammar class with an empty thread stack.

Method Detail

insertWord

public void insertWord(WordPackage wordPack)
                throws GrammarParseException
Inserts a new word string into the current grammar. Every WordSense has its grammar tree, which is a BooleanTree, added to the grammar. Each word sense of the new word creates a new thread in the grammar, which may or may not be valid.

Parameters:
wordPack - WordPackage of the word to insert
Throws:
GrammarParseException - thrown if the grammar string in the database was not able to be parsed.
See Also:
WordSense, BooleanTree, WordPackage

finalizeSentence

public java.util.Vector finalizeSentence()
Ensures all threads are valid by checking to see there are no open links that have not been satisfied. Every valid sentence thread is returned in a Vector to the caller.

Returns:
Vector of Vectors containing Link classes with all valid linkages
See Also:
Link

getThreads

public java.util.Vector getThreads()
This method returns all of the sentence threads. This method is used by the GrammarWorkbench to draw the current state of the grammar. This method may be called in the middle of parsing a sentence, which means the SentenceThread may have open links.

Returns:
Vector containing a list of all current sentence threads
See Also:
SentenceThread

Fido Alpha 3.2