Natural Language Processing  0.1.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | Friends | List of all members
Grammar Class Reference

The Grammar class A generic Grammar class that contains a multimap. It maps a Grammar Phrase to a vector of Grammar Phrases. This denotes the definition of the Grammar Phrase to other Grammar Phrases. There may be more than one definition for a Grammar Phrase. More...

#include <grammar.h>

Inheritance diagram for Grammar:
CFGQ CFGQ CFGZero CFGZero

Public Member Functions

 Grammar ()
 Grammar::Grammar Default Constructor. Creates a new multimap with a single blank definition for a sentence. The reason for the initial sentence definition is because ALL grammar structures MUST begin with a sentence definition.
 
void addRule (const GrammarPhrase &define, const GPlist &rule)
 Grammar::addRule Adds the specified relationship by creating and adding a pair in the multimap. More...
 
void removeRule (const GrammarPhrase &define, const GPlist &rule)
 Grammar::removeRule Removes the specified rule by finding and deleting it from the multimap. More...
 
std::vector< GPlistgetDefinition (const GrammarPhrase &define)
 Grammar::getDefinition Returns the definitions of the specified phrase. More...
 
GrammarPhrase getDefiner (const GPlist &rule)
 Grammar::getDefiner Returns the phrase whose definition is the same as the one specified. More...
 
void addRule (const GrammarPhrase &define, const GPlist &rule)
 
void removeRule (const GrammarPhrase &define, const GPlist &rule)
 
std::vector< GPlistgetDefinition (const GrammarPhrase &define)
 
GrammarPhrase getDefiner (const GPlist &rule)
 

Friends

std::ostream & operator<< (std::ostream &out, const Grammar &G)
 operator << insertion operator. Writes out the Grammar Structure to the out stream More...
 
std::ostream & operator<< (std::ostream &out, const Grammar &G)
 operator << insertion operator. Writes out the Grammar Structure to the out stream More...
 

Detailed Description

The Grammar class A generic Grammar class that contains a multimap. It maps a Grammar Phrase to a vector of Grammar Phrases. This denotes the definition of the Grammar Phrase to other Grammar Phrases. There may be more than one definition for a Grammar Phrase.

Member Function Documentation

void Grammar::addRule ( const GrammarPhrase define,
const GPlist rule 
)

Grammar::addRule Adds the specified relationship by creating and adding a pair in the multimap.

Parameters
defineThis is the LHS of the definition. This is what is being defined, i.e. the key
ruleThis is the RHS. This is the definition, i.e. the value NOTE: This will take care of the empty sentence definition
GrammarPhrase Grammar::getDefiner ( const GPlist rule)

Grammar::getDefiner Returns the phrase whose definition is the same as the one specified.

Parameters
rulethe definition
Returns
the phrase that corresponds to the rule NOTE: If the phrase is G_INVALID, then the definer was not found
std::vector< GPlist > Grammar::getDefinition ( const GrammarPhrase define)

Grammar::getDefinition Returns the definitions of the specified phrase.

Parameters
definethe phrase whose definitions are desired
Returns
a vector of grammarphrases NOTE: If the vector is empty, then there were no definitions found
void Grammar::removeRule ( const GrammarPhrase define,
const GPlist rule 
)

Grammar::removeRule Removes the specified rule by finding and deleting it from the multimap.

Parameters
defineThe phrase that is defined by the rule
ruleThe definition itself NOTE: No need for finding the exact position in the map. Just create a copy of the definition and pass it in.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const Grammar G 
)
friend

operator << insertion operator. Writes out the Grammar Structure to the out stream

Parameters
outthe output stream
Gthe Grammar Structure
Returns
the output stream reference
std::ostream& operator<< ( std::ostream &  out,
const Grammar G 
)
friend

operator << insertion operator. Writes out the Grammar Structure to the out stream

Parameters
outthe output stream
Gthe Grammar Structure
Returns
the output stream reference

The documentation for this class was generated from the following files: