Overview | Package | Class | Tree | Index | Help | |||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.speech.recognition.Rule | +--javax.speech.recognition.RuleAlternatives
RuleAlternatives
represents a Rule
composed of a
set of alternative sub-rules. RuleAlternatives
are used to
construct RuleGrammar
objects. A RuleAlternatives
object is spoken by saying one, and only one, of of its sub-rules.
A RuleAlternatives
object contains a set of zero or more
Rule
objects. A set of zero alternatives is equivalent to
<VOID>
(it is unspeakable).
Weights may be (optionally) assigned to each alternative rule.
The weights indicate the chance of each Rule
being spoken.
The setWeights
method defines the constraints upon weights.
If no weights are defined, then all alternatives are considered
equally likely.
Field Summary | |
Rule[] | rules
Set of alternative Rule objects. |
float[] | weights
Array of weights for each alternative Rule
or null if the rules are equally likely.
|
Constructor Summary | |
RuleAlternatives(Rule[] rules,
float[] weights)
Construct a RuleAlternatives object with an array of
sub-rules and an array of weights. |
|
RuleAlternatives(Rule[] rules)
Construct a RuleAlternatives object with an array of sub-rules.
|
|
RuleAlternatives(Rule rule)
Construct a RuleAlternatives object containing a single sub-rule.
|
|
RuleAlternatives()
Empty constructor creates zero-length list of alternatives. |
|
RuleAlternatives(String[] tokens)
Constructor for RuleAlternatives that produces a
phrase list from an array of String objects. |
Method Summary | |
void | append(Rule rule)
Append a single rule to the set of alternatives. |
Rule | copy()
Return a deep copy of this rule. |
Rule[] | getRules()
Return the array of alternative sub-rules. |
float[] | getWeights()
Return the array of weights. |
void | setRules(Rule[] rules)
Set the array of alternative sub-rules. |
void | setWeights(float[] weights)
Set the array of weights for the rules. |
String | toString()
Return a String representing this object as partial
Java Speech Grammar Format. |
Methods inherited from class javax.speech.recognition.Rule | |
copy, toString |
Methods inherited from class java.lang.Object | |
clone, equals, finalize, getClass, hashCode, notifyAll, notify, toString, wait, wait, wait |
Field Detail |
protected Rule[] rules
Rule
objects.protected float[] weights
Rule
or null
if the rules are equally likely.
If non-null, the weights
array must have an
identical length to the rules
array.Constructor Detail |
public RuleAlternatives(Rule[] rules, float[] weights) throws IllegalArgumentException
RuleAlternatives
object with an array of
sub-rules and an array of weights. The rules array and weights
array may be null
. If the weights array is non-null,
it must have identical length to the rules array.
rules
- the set of alternative sub-rules
set
- of weights for each rule or null
setWeights
).public RuleAlternatives(Rule[] rules)
RuleAlternatives
object with an array of sub-rules.
The weights are set to null
.
rules
- the set of alternative sub-rulespublic RuleAlternatives(Rule rule)
RuleAlternatives
object containing a single sub-rule.
The weights array is set to null
.public RuleAlternatives()
setRules
method or append method to
add alternatives.
A zero-length set of alternatives is equivalent to
<VOID>
(i.e. unspeakable).
public RuleAlternatives(String[] tokens)
RuleAlternatives
that produces a
phrase list from an array of String
objects. Each
string is used to create a single RuleToken
object.
A string containing multiple words (e.g. "san francisco") is treated as a single token. If appropriate, an application should parse such strings to produce separate tokens.
The phrase list may be zero-length or null. This will produce an
empty set of alternatives which is equivalent to <VOID>
(i.e. unspeakable).
tokens
- a set of alternative tokensMethod Detail |
public Rule[] getRules()
public void setRules(Rule[] rules)
If the weights are non-null and the number of rules is
not equal to the number of weights, the weights are set to null
.
To change the number of rules and weights, call setRules
before
setWeights
.
public void append(Rule rule)
null
.public float[] getWeights()
null
.
If non-null, the length of the weights array is guaranteed to be
the same length as the array of rules.public void setWeights(float[] weights) throws IllegalArgumentException
weights
array may be null
.
If the weights are null
, then all alternatives are
assumed to be equally likely.
The length of the weights array must be the same length as the array of rules. The weights must all be greater than or equal to 0.0 and at least one must be non-zero.
To change the number of rules and weights, first call
setRules
.
public Rule copy()
Rule.copy
documentation for an explanation of deep copy.public String toString()
String
representing this object as partial
Java Speech Grammar Format. The string is a legal right hand side
of a rule definition.Overview | Package | Class | Tree | Index | Help | |||
PREV CLASS | NEXT CLASS | FRAMES | NO FRAMES | ||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
JavaTM Speech API
Copyright 1997-1998 Sun Microsystems, Inc. All rights reserved
Send comments to javaspeech-comments@sun.com