JSAPI 2.0

javax.speech.recognition
Class RuleCount

Object
  extended by RuleComponent
      extended by RuleCount

public class RuleCount
extends RuleComponent

Attaches repeat counts to a contained RuleComponent object to indicate the number of times it may occur.

The contained RuleComponent may occur optionally (zero or one times), zero or more times, one or more times, up to a maximum, at least a minimum, and within a range. This class supports the following common cases from formal language theory: "[]" (optional), "*" (zero or more - Kleene star) and "+" (one or more - positive closure).

Any RuleComponent not contained by a RuleCount object occurs once only.

Probabilities normally in the range of 0 to 1.0 should be scaled to the range of 0 to MAX_PROBABILITY.

See Also:
MAX_PROBABILITY

Field Summary
static int MAX_PROBABILITY
          The maximum repeat probability for a RuleCount.
static int REPEAT_INDEFINITELY
          A value that represents indefinite repeating for a RuleCount.
 
Constructor Summary
RuleCount(RuleComponent ruleComponent, int repeatMin)
          Constructs a RuleCount specifying the minimum number of times a RuleComponent must repeat.
RuleCount(RuleComponent ruleComponent, int repeatMin, int repeatMax)
          Constructs a RuleCount specifying a range for repeating a RuleComponent.
RuleCount(RuleComponent ruleComponent, int repeatMin, int repeatMax, int repeatProbability)
          Constructs a RuleCount specifying a range for repeating a RuleComponent with a probability.
 
Method Summary
 int getRepeatMax()
          Returns the maximum repeat count for this RuleCount.
 int getRepeatMin()
          Returns the minimum repeat count for this RuleCount.
 int getRepeatProbability()
          Returns the repeat probability for this RuleCount.
 RuleComponent getRuleComponent()
          Returns the RuleComponent to which the counts and probability apply.
 String toString()
          Returns a String representing this RuleComponent as grammar text.
 
Methods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

MAX_PROBABILITY

public static final int MAX_PROBABILITY
The maximum repeat probability for a RuleCount.

Probabilities normally in the range of 0 to 1.0 should be scaled to the range of 0 to MAX_PROBABILITY.

See Also:
RuleCount(RuleComponent, int, int, int), Constant Field Values

REPEAT_INDEFINITELY

public static final int REPEAT_INDEFINITELY
A value that represents indefinite repeating for a RuleCount.

See Also:
RuleCount(RuleComponent, int, int, int), Constant Field Values
Constructor Detail

RuleCount

public RuleCount(RuleComponent ruleComponent,
                 int repeatMin)
          throws IllegalArgumentException
Constructs a RuleCount specifying the minimum number of times a RuleComponent must repeat.

repeatMin of 0 represents 0 or more (Kleene star) and repeatMin of 1 represents the positive closure.

repeatMin must be greater than or equal to 0.

Parameters:
ruleComponent - the RuleComponent to which the counts apply
repeatMin - the minimum repeat count
Throws:
IllegalArgumentException - if repeatMin is less than 0
See Also:
getRuleComponent, getRepeatMin

RuleCount

public RuleCount(RuleComponent ruleComponent,
                 int repeatMin,
                 int repeatMax)
          throws IllegalArgumentException
Constructs a RuleCount specifying a range for repeating a RuleComponent.

A repeatMin of 0 and a repeatMax of 1 means that this RuleComponent is optional.

repeatMin must be greater than or equal to 0 and less than or equal to repeatMax.

Parameters:
ruleComponent - the RuleComponent to which the counts apply
repeatMin - the minimum repeat count
repeatMax - the maximum repeat count
Throws:
IllegalArgumentException - if repeatMin is less than 0 or if repeatMin is greater than repeatMax
See Also:
getRuleComponent, getRepeatMin, getRepeatMax

RuleCount

public RuleCount(RuleComponent ruleComponent,
                 int repeatMin,
                 int repeatMax,
                 int repeatProbability)
          throws IllegalArgumentException
Constructs a RuleCount specifying a range for repeating a RuleComponent with a probability.

repeatMin must be greater than or equal to 0 and less than or equal to repeatMax. repeatProbability must be between 0 and MAX_PROBABILITY.

When repeatMax is REPEAT_INDEFINITELY, the ruleComponent is repeated an indefinite number of times.

Parameters:
ruleComponent - the RuleComponent to which the counts apply
repeatMin - the minimum repeat count
repeatMax - the maximum repeat count
repeatProbability - the repeat probability
Throws:
IllegalArgumentException - if repeatMin is less than 0 or if repeatMin is greater than repeatMax or if repeatProbability is not with range
See Also:
getRuleComponent, getRepeatMin, getRepeatMax, getRepeatProbability, MAX_PROBABILITY, REPEAT_INDEFINITELY
Method Detail

getRepeatMin

public int getRepeatMin()
Returns the minimum repeat count for this RuleCount.

Returns:
the minimum repeat count for this RuleCount

getRepeatMax

public int getRepeatMax()
Returns the maximum repeat count for this RuleCount.

Returns REPEAT_INDEFINITELY if not specified in the constructor.

Returns:
the maximum repeat count for this RuleCount

getRepeatProbability

public int getRepeatProbability()
Returns the repeat probability for this RuleCount.

Returns MAX_PROBABILITY if not specified in the constructor.

Returns:
the repeat probability for this RuleCount

getRuleComponent

public RuleComponent getRuleComponent()
Returns the RuleComponent to which the counts and probability apply.

Returns:
the RuleComponent to which the counts and probability apply.

toString

public String toString()
Returns a String representing this RuleComponent as grammar text. The String represents a portion of a grammar that could appear on the right hand side of a Rule definition.

Overrides:
toString in class RuleComponent
Returns:
printable String representing grammar text.
See Also:
RuleComponent, Rule

JSAPI 2.0

JavaTM Speech API 2.0, Final Release v2.0.6.
© 2008, Conversay and Sun Microsystems.

Free Web Hosting