|
JSAPI 2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface FinalRuleResult
Provides information on a finalized Result
for
an utterance that matches a RuleGrammar
.
A finalized Result
is a Result
that has received
a RESULT_ACCEPTED
or RESULT_REJECTED
event that puts it
in either the ACCEPTED
or REJECTED
state
as indicated by the getResultState
method.
The methods this interface should only be called
on a finalized Result
object if
the Result.getGrammar
method returns a RuleGrammar
.
Otherwise, a ResultStateException
is thrown.
RuleGrammar
s loaded and active for recognition.
The first is "grammar:numbers"
with a root Rule
"digits"
that matches spoken digit sequences (for example, "1 2 3 4"
).
The second is "grammar:food"
with the root Rule
"whoAteWhat"
that matches statements about eating (for example, "he ate mine"
).
The user says "two eight nine"
and the Recognizer
correctly
recognizes the speech, but provides 2 additional alternatives.
FinalRuleResult result = ...;
result.getNumberAlternatives() -> 3
result.getAlternativeTokens(0) -> {"two", "eight", "nine"}
result.getRuleReference(0) -> new RuleReference("grammar:numbers", "digits")
result.getAlternativeTokens(1) -> {"you", "ate", "mine"}
result.getRuleName(1) -> new RuleReference("grammar:food", "whoAteWhat")
result.getAlternativeTokens(2) -> {"two", "eight", "five"}
result.getRuleName(2) -> new RuleReference("grammar:numbers", "digits")
RuleGrammar
,
ACCEPTED
,
REJECTED
,
getResultState
,
getGrammar
,
RESULT_ACCEPTED
,
RESULT_REJECTED
Field Summary |
---|
Fields inherited from interface FinalResult |
---|
DONT_KNOW, MISRECOGNITION, USER_CHANGE |
Fields inherited from interface Result |
---|
ACCEPTED, REJECTED, UNFINALIZED |
Method Summary | |
---|---|
RuleReference |
getRuleReference(int nBest)
Returns the RuleReference matched by the Nth-best alternative. |
Object[] |
getTags(int nBest)
Returns the list of tags matched by the token sequence for the Nth-best alternative. |
RuleParse |
parse(int nBest)
Returns the RuleParse corresponding to the Nth-best alternative. |
Methods inherited from interface FinalResult |
---|
getAlternativeTokens, getAudio, getAudio, getConfidenceLevel, getConfidenceLevel, getGrammar, getNumberAlternatives, isAudioAvailable, isTrainingInfoAvailable, releaseAudio, releaseTrainingInfo, tokenCorrection |
Methods inherited from interface Result |
---|
addResultListener, getBestToken, getBestTokens, getGrammar, getNumTokens, getResultState, getUnfinalizedTokens, removeResultListener |
Method Detail |
---|
RuleReference getRuleReference(int nBest) throws ResultStateException, IllegalArgumentException, IllegalStateException
RuleReference
matched by the Nth-best alternative.
The range for nBest
is
0
to (getNumberAlternatives()-1)
, inclusive,
where 0
represents the best alternative.
A REJECTED
Result
is not guaranteed to return
a RuleReference
and null
may be returned instead.
This method uses Grammar
s committed with the last
call to resume
before Result
finalization and
throws an IllegalStateException
if Grammar
changes
are subsequently committed by resume
.
nBest
- the Nth-Best index
RuleReference
matched by the nBest
alternative
ResultStateException
- if called before this Result
is finalized
IllegalArgumentException
- if nBest
is not in range
IllegalStateException
- if Grammar
changes are subsequently
committed by resume
getNumberAlternatives
,
getAlternativeTokens
,
getGrammar
,
REJECTED
,
resume
Object[] getTags(int nBest) throws ResultStateException, IllegalArgumentException, IllegalStateException
The range for nBest
is
0
to (getNumberAlternatives()-1)
, inclusive,
where 0
represents the best alternative.
A REJECTED
Result
is not guaranteed
to return tags and an empty list may be returned instead.
This method uses Grammar
s committed with the last
call to resume
before Result
finalization and
throws an IllegalStateException
if Grammar
changes
are subsequently committed by resume
.
For a FinalRuleResult
, the tags in the array are listed in the
order in which they are encountered in the RuleGrammar
.
For example, if the RuleGrammar
contains the following root rule:
<rule id='actionRule'>
<one-of>
<item> open <tag>ACT_OPEN</tag> </item>
<item> close <tag>ACT_CLOSE</tag> </item>
</one-of>
<item repeat='0-1'> <!-- optional -->
<item>
it <tag>WHAT</tag> now <tag>NOW</tag>
</item>
</item>
</rule>
and the user says "close it now"
,
then getTags
returns an array
containing {"ACT_CLOSE", "WHAT", "NOW"}
.
Tags in RuleGrammar
s created from markup text will always
be String
s, but tags created with RuleTag
can be any Object
.
getTags
does not indicate which tokens occur near which tags.
Use the parse
method to obtain this information.
This method behaves the same as
parse(nBest).getTags()
,
but may be more efficient.
getTags
in interface FinalResult
nBest
- the Nth-Best index
nBest
alternative
ResultStateException
- if called before this Result
is finalized
IllegalArgumentException
- if nBest
is not in range
IllegalStateException
- if Grammar
changes are subsequently
committed by resume
getNumberAlternatives
,
getBestTokens
,
parse
,
RuleParse.getTags
,
REJECTED
,
resume
RuleParse parse(int nBest) throws ResultStateException, IllegalArgumentException, IllegalStateException
RuleParse
corresponding to the Nth-best alternative.
The range for nBest
is
0
to (getNumberAlternatives()-1)
, inclusive,
where 0
represents the best alternative.
A REJECTED
Result
is not guaranteed to return
a RuleParse
and null
may be returned instead.
This method is essentially the same as the RuleGrammar.parse
method given the same nBest
tokens and starting rule name.
However,
this method uses Grammar
s committed with the last
call to resume
before Result
finalization and
throws an IllegalStateException
if subsequent Grammar
changes
are committed by resume
.
nBest
- the Nth-Best index
RuleParse
corresponding to the nBest
alternative or possibly null
for a REJECTED
Result
.
ResultStateException
- if called before this Result
is finalized
IllegalArgumentException
- if nBest
is not in range
IllegalStateException
- if Grammar
changes are subsequently
committed by resume
getNumberAlternatives
,
RuleGrammar.parse(String[],String)
,
getAlternativeTokens
,
getRuleReference
,
REJECTED
,
resume
|
JSAPI 2.0 | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
JavaTM Speech API 2.0,
Final Release v2.0.6.
© 2008, Conversay and Sun Microsystems.