|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.cmu.sphinx.linguist.language.grammar.Grammar
public abstract class Grammar
Classes that implement this interface create grammars. A grammar is represented internally as a graph of GrammarNodes
linked together by GrammarArcs
. Calling getInitialNode
will return the first node of the grammar graph. To traverse the grammar graph, one should call
GrammarNode.getSuccessors, which will return an array of GrammarArcs, from which you can reach the neighboring
GrammarNodes.
Field Summary | |
---|---|
static java.lang.String |
PROP_ADD_FILLER_WORDS
Property to control whether filler words are inserted into the graph |
static java.lang.String |
PROP_ADD_SIL_WORDS
Property to control whether silence words are inserted into the graph |
static java.lang.String |
PROP_DICTIONARY
Property that defines the dictionary to use for this grammar |
static java.lang.String |
PROP_OPTIMIZE_GRAMMAR
The default value for PROP_SHOW_GRAMMAR. |
static java.lang.String |
PROP_SHOW_GRAMMAR
Property to control the the dumping of the grammar |
Constructor Summary | |
---|---|
Grammar()
|
Method Summary | |
---|---|
void |
allocate()
Create the grammar |
void |
deallocate()
Deallocate resources allocated to this grammar |
void |
dumpGrammar(java.lang.String name)
Dumps the grammar |
void |
dumpRandomSentences(int count)
Dump a set of random sentences that fit this grammar |
void |
dumpRandomSentences(java.lang.String path,
int count)
Dump a set of random sentences that fit this grammar |
void |
dumpStatistics()
Dumps statistics for this grammar |
Dictionary |
getDictionary()
Gets the dictionary for this grammar |
java.util.Set<GrammarNode> |
getGrammarNodes()
returns the set of of nodes in this grammar |
GrammarNode |
getInitialNode()
Returns the initial node for the grammar |
int |
getNumNodes()
returns the number of nodes in this grammar |
java.lang.String |
getRandomSentence()
Returns a random sentence that fits this grammar |
void |
newProperties(PropertySheet ps)
This method is called when this configurable component needs to be reconfigured. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
@S4Boolean(defaultValue=false) public static final java.lang.String PROP_SHOW_GRAMMAR
@S4Boolean(defaultValue=true) public static final java.lang.String PROP_OPTIMIZE_GRAMMAR
@S4Boolean(defaultValue=false) public static final java.lang.String PROP_ADD_SIL_WORDS
@S4Boolean(defaultValue=false) public static final java.lang.String PROP_ADD_FILLER_WORDS
@S4Component(type=Dictionary.class) public static final java.lang.String PROP_DICTIONARY
Constructor Detail |
---|
public Grammar()
Method Detail |
---|
public void newProperties(PropertySheet ps) throws PropertyException
Configurable
newProperties
in interface Configurable
ps
- a property sheet holding the new data
PropertyException
- if there is a problem with the properties.public void allocate() throws java.io.IOException
java.io.IOException
public void deallocate()
public GrammarNode getInitialNode()
getInitialNode
in interface GrammarInterface
public void dumpStatistics()
public void dumpRandomSentences(java.lang.String path, int count)
path
- the name of the file to dump the sentences tocount
- dumps no more than this. May dump less than this depending upon the number of uniqe sentences in the
grammar.public void dumpRandomSentences(int count)
count
- dumps no more than this. May dump less than this depending upon the number of uniqe sentences in the
grammar.public java.lang.String getRandomSentence()
public void dumpGrammar(java.lang.String name)
public int getNumNodes()
public java.util.Set<GrammarNode> getGrammarNodes()
getGrammarNodes
in interface GrammarInterface
public Dictionary getDictionary()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |