ITCS 6010 XML Grammars What is a Grammar

  • Slides: 10
Download presentation
ITCS 6010 XML Grammars

ITCS 6010 XML Grammars

What is a Grammar? n Specifies what can be said—all the possible sentences and

What is a Grammar? n Specifies what can be said—all the possible sentences and phrases that can be recognized n Includes entry via speech or touchpad

XML Grammar Tags n n <rule> <item> <one-of> <count>

XML Grammar Tags n n <rule> <item> <one-of> <count>

<rule> n <rule id = “string” scope = “string”/> n n Associates a legal

<rule> n <rule id = “string” scope = “string”/> n n Associates a legal rule expansion with a rulename Has two attributes n n id – name of rule; must be unique within grammar scope – has two options: public or private n n public – may be explicitly referenced by other grammars private – only directly accessible within containing grammar (default)

<item> n <item tag = “string” weight = “string”/> n n Defines an expression

<item> n <item tag = “string” weight = “string”/> n n Defines an expression that can be uttered by user Has two attributes n n tag – value returned by recognizer if item matched weight – value indicates likelihood user will utter item n n Floating point value >0

<one-of> n <one-of tag = “string”/> n n Defines set of alternative expressions Has

<one-of> n <one-of tag = “string”/> n n Defines set of alternative expressions Has one attribute n tag – value returned if contained expression matched

<count> n <count number = “string”/> n n Defines # times contained expression can

<count> n <count number = “string”/> n n Defines # times contained expression can be uttered by user Has one attribute n number – can have 4 values: n n 0+ - contained expressed may be uttered 0 or more times 1+ - contained expression may be uttered 1 or more times ? – contained expression optional

<ruleref> n <ruleref tag = “string” uri = “string”/> n n Defines a rule

<ruleref> n <ruleref tag = “string” uri = “string”/> n n Defines a rule element Has two attributes tag – value returned by recognizer if ruleref matched n uri – uri to a rule n

<ruleref> (cont’d) n uri can have special definitions n n n <ruleref special="NULL"/> -

<ruleref> (cont’d) n uri can have special definitions n n n <ruleref special="NULL"/> - rule that is automatically matched without user uttering a word <ruleref special="VOID"/> - a rule that can never be spoken <ruleref special="GARBAGE"/> - a rule that matches any speech up until next rule match/next token/end of spoken input

Grammar Example n <grammar mode="voice" xml: lang="en-US"> <!-- Command is an action on an

Grammar Example n <grammar mode="voice" xml: lang="en-US"> <!-- Command is an action on an object --> <!-- e. g. "open a window" --> <rule id="command" scope="public"> <ruleref uri="#action"/> <ruleref uri="#object"/> </rule> <rule id="action"> <one-of> <item> open </item> <item> close </item> <item> delete </item> <item> move </item> </one-of> </rule> <rule id="object"> <count number="optional"> <one-of> <item> the </item> <item> a </item> </one-of> </count> <one-of> <item> window </item> <item> file </item> <item> menu </item> </one-of> </rule> </grammar>