SR_Grammar Struct Reference
[SR_Grammar API functions]


Detailed Description

Contains recognition grammar.

A grammar consists of a list of rules.

A rule consists of a list of words and slots. For example: MY_RULE = "My name is $name" where "name" is a slot

Words, Nametags may be added or removed from slots. Upon adding and removing words, the grammar needs to be recompiled for the changes to take place. However, the original CompiledGrammar remains valid even if compilation never takes place.

Two types of slots exist: word slots and nametag slots

Data Fields

ESR_ReturnCode(* compile )(struct SR_Grammar_t *self)
ESR_ReturnCode(* save )(struct SR_Grammar_t *self, const LCHAR *filename)
ESR_ReturnCode(* checkParse )(struct SR_Grammar_t *self, const LCHAR *transcription, SR_SemanticResult **result, size_t *resultCount)
ESR_ReturnCode(* addWordToSlot )(struct SR_Grammar_t *self, const LCHAR *slot, const LCHAR *word, const LCHAR *pronunciation, int weight, const LCHAR *tag)
ESR_ReturnCode(* resetAllSlots )(struct SR_Grammar_t *self)
ESR_ReturnCode(* addNametagToSlot )(struct SR_Grammar_t *self, const LCHAR *slot, const SR_Nametag *nametag, int weight, const LCHAR *tag)
ESR_ReturnCode(* setDispatchFunction )(struct SR_Grammar_t *self, const LCHAR *name, void *userData, SR_GrammarDispatchFunction function)
ESR_ReturnCode(* setParameter )(struct SR_Grammar_t *self, const LCHAR *key, void *value)
ESR_ReturnCode(* setSize_tParameter )(struct SR_Grammar_t *self, const LCHAR *key, size_t value)
ESR_ReturnCode(* getParameter )(struct SR_Grammar_t *self, const LCHAR *key, void **value)
ESR_ReturnCode(* getSize_tParameter )(struct SR_Grammar_t *self, const LCHAR *key, size_t *value)
ESR_ReturnCode(* setupVocabulary )(struct SR_Grammar_t *self, SR_Vocabulary *vocabulary)
ESR_ReturnCode(* setupRecognizer )(struct SR_Grammar_t *self, struct SR_Recognizer_t *recognizer)
ESR_ReturnCode(* unsetupRecognizer )(struct SR_Grammar_t *self)
ESR_ReturnCode(* destroy )(struct SR_Grammar_t *self)


Field Documentation

ESR_ReturnCode(* SR_Grammar::compile)(struct SR_Grammar_t *self)

Compiles the grammar. In the case of a precompiled grammar, the function compiles those portions of the grammar that were dynamically added since the last compilation.

Parameters:
self SR_Grammar handle
Returns:
ESR_SUCCESS if compilation succeeded, ESR_FATAL_ERROR otherwise.

ESR_ReturnCode(* SR_Grammar::save)(struct SR_Grammar_t *self, const LCHAR *filename)

Saves a compiled grammar to a file.

Parameters:
self SR_Grammar handle
filename File to write grammar into
Returns:
ESR_INVALID_ARGUMENT if self or filename are null; ESR_INVALID_STATE if could not save the grammar

ESR_ReturnCode(* SR_Grammar::checkParse)(struct SR_Grammar_t *self, const LCHAR *transcription, SR_SemanticResult **result, size_t *resultCount)

Indicates if a transcription is a valid result of a Grammar rule.

Parameters:
self SR_Grammar handle
transcription Transcription value
result [in/out] Array of semantic results to be populated
resultCount [in/out] Length of result array
Returns:
ESR_INVALID_ARGUMENT if self or transcription are null; ESR_INVALID_STATE if an internal error has occured.

ESR_ReturnCode(* SR_Grammar::addWordToSlot)(struct SR_Grammar_t *self, const LCHAR *slot, const LCHAR *word, const LCHAR *pronunciation, int weight, const LCHAR *tag)

Adds word to rule slot.

Parameters:
self SR_Grammar handle
slot Slot name
word Word to be added to the slot
pronunciation Word pronunciation (optional). Pass NULL to omit.
weight value to associate with word when adding to grammar; use to determine cost when parsing
tag eScript semantic expression (tag) for the word
Returns:
ESR_INVALID_ARGUMENT if self is null; ESR_INVALID_STATE if the vocabulary is missing, if OSI logging fails; ESR_OUT_OF_MEMORY if word cannot be added to the grammar (addWords=X is too small); ESR_NOT_SUPPORTED if homonyms are added to the grammar

ESR_ReturnCode(* SR_Grammar::resetAllSlots)(struct SR_Grammar_t *self)

Removes all elements from all slots.

Parameters:
self SR_Grammar handle
Returns:
ESR_INVALID_ARGUMENT if self is null; ESR_INVALID_STATE if resetting the slots or OSI logging fails

ESR_ReturnCode(* SR_Grammar::addNametagToSlot)(struct SR_Grammar_t *self, const LCHAR *slot, const SR_Nametag *nametag, int weight, const LCHAR *tag)

Adds nametag to rule slot.

Parameters:
self SR_Grammar handle
slot Slot name
nametag Nametag to be added to the grammar
weight value to associate with nametag when adding to grammar; use to determine cost when parsing
tag eScript semantic expression (tag) for the nametag
Returns:
ESR_INVALID_ARGUMENT if self is null; ESR_INVALID_STATE if the grammar is active, if the vocabulary is missing, if OSI logging fails; ESR_OUT_OF_MEMORY if word cannot be added to the grammar (addWords=X is too small); ESR_NOT_SUPPORTED if homonyms are added to the grammar

ESR_ReturnCode(* SR_Grammar::setDispatchFunction)(struct SR_Grammar_t *self, const LCHAR *name, void *userData, SR_GrammarDispatchFunction function)

Sets user dispatch function (used for parsed callback, etc)

Parameters:
self SR_Grammar handle
name The name of the function which will trigger this callback when encountered during grammar parsing.
userData The user data to be referenced in the callback implementation later on.
function The dispatch function
Returns:
ESR_INVALID_ARGUMENT if self is null; ESR_SUCCESS

ESR_ReturnCode(* SR_Grammar::setParameter)(struct SR_Grammar_t *self, const LCHAR *key, void *value)

Sets grammar parameter, overriding session defaults.

Parameters:
self SR_Grammar handle
key Parameter name
value Parameter value
Returns:
ESR_INVALID_ARGUMENT if self is null; ESR_NOT_IMPLEMENTED

ESR_ReturnCode(* SR_Grammar::setSize_tParameter)(struct SR_Grammar_t *self, const LCHAR *key, size_t value)

Sets grammar parameters. This is a convenience function.

Parameters:
self SR_Grammar handle
key Parameter name
value Parameter value
Returns:
ESR_INVALID_ARGUMENT if self is null; ESR_INVALID_RESULT_TYPE if the property is already set and its type is size_t

ESR_ReturnCode(* SR_Grammar::getParameter)(struct SR_Grammar_t *self, const LCHAR *key, void **value)

Returns grammar parameter value.

Parameters:
self SR_Grammar handle
key Parameter name
value Parameter value
Returns:
ESR_INVALID_ARGUMENT if self is null; ESR_NOT_IMPLEMENTED

ESR_ReturnCode(* SR_Grammar::getSize_tParameter)(struct SR_Grammar_t *self, const LCHAR *key, size_t *value)

Return copy of unsigned int grammar parameter. This is a convenience function.

Parameters:
self SR_Grammar handle
key Parameter name
value [out] Used to hold the parameter value
len [in/out] Length of value argument. If the return code is ESR_BUFFER_OVERFLOW, the required length is returned in this variable.
Returns:
ESR_INVALID_ARGUMENT if self is null; ESR_INVALID_RESULT_TYPE if the property type is not size_t; ESR_NO_MATCH_ERROR if property is not set

ESR_ReturnCode(* SR_Grammar::setupVocabulary)(struct SR_Grammar_t *self, SR_Vocabulary *vocabulary)

Configures a vocabulary with the grammar.

Parameters:
self SR_Grammar handle
vocabulary The vocabulary to associate with
Returns:
ESR_INVALID_ARGUMENT if self or vocabulary are null

ESR_ReturnCode(* SR_Grammar::setupRecognizer)(struct SR_Grammar_t *self, struct SR_Recognizer_t *recognizer)

Associates Recognizer with the grammar.

Parameters:
self SR_Grammar handle
recognizer The recognizer to associate
Returns:
ESR_INVALID_ARGUMENT if self or recognizer are null

ESR_ReturnCode(* SR_Grammar::unsetupRecognizer)(struct SR_Grammar_t *self)

Dissociates Recognizer with the grammar.

Parameters:
self SR_Grammar handle
Returns:
ESR_INVALID_ARGUMENT if self is null

ESR_ReturnCode(* SR_Grammar::destroy)(struct SR_Grammar_t *self)

Returns AcousticModels associated with the grammar.

Parameters:
self SR_Grammar handle
models Associated models
Returns:
ESR_INVALID_ARGUMENT if self or models are null Destroys a grammar.
Parameters:
self SR_Grammar handle
Returns:
ESR_INVALID_ARGUMENT if self is null, ESR_INVALID_STATE if OSI logging fails


Generated on Thu May 1 15:37:28 2008 for SREC by  doxygen 1.5.3