Home | History | Annotate | Download | only in grammars
      1 <?xml version="1.0" encoding="ISO8859-1" ?>
      2 <grammar xml:lang="en-us" version="1.0" root="ROOT" xmlns="http://www.w3.org/2001/06/grammar"      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xsi:schemaLocation="http://www.w3.org/2001/06/grammar http://www.w3.org/TR/speech-grammar/grammar.xsd">
      3 <meta name="word_penalty" content="40" />
      4 <!-- 
      5 	Lookup name grammar, this is a sample grammar that can recognize
      6 	lookup followed by a digit string or a name.  Names can be followed
      7 	by a place (such as office, home, mobile).  The return key value pairs
      8 	in two cases are shown below.
      9 # parseStringTest.out -base lookup 
     10 )) parse ok (1 results) (lookup Wilson at office) (8)
     11 {LOOKUP.PLACE : office}
     12 {ROOT.M_P : office}
     13 {meaning : office Wilson }
     14 {NAMES.N : Wilson}
     15 {LOOKUP.NAME : Wilson}
     16 {ROOT.M_N : Wilson}
     17 {PLACES.P : office}
     18 {ROOT.M_T : }
     19 --Done--
     20 ) parse ok (1 results) (lookup seven one) (7)
     21 {ROOT.M_P : }
     22 {DIGIT.V : 1}
     23 {LOOKUP.TELN : 71}
     24 {S.X : 71}
     25 {meaning : 71}
     26 {ROOT.M_N : }
     27 {ROOT.M_T : 71}
     28 -->
     29 <rule id="ROOT" scope="public">
     30         <item>
     31 	  <ruleref uri="#LOOKUP"/>
     32 	  <tag>M_N=LOOKUP.NAME?LOOKUP.NAME:'';
     33                M_P=LOOKUP.PLACE?LOOKUP.PLACE:'';
     34                M_T=LOOKUP.TELN?LOOKUP.TELN:'';</tag>
     35 	</item>
     36 </rule>
     37 
     38    <rule id="LOOKUP">
     39      <item>lookup</item>
     40      <one-of>
     41 	<item>
     42 	   <ruleref uri="#NAMES"/>
     43 	   <item repeat="0-1">
     44 		<item>at</item>
     45 		<ruleref uri="#PLACES"/>
     46 		<tag>PLACE=PLACES.P</tag>
     47 	   </item>
     48 	   <tag>NAME=NAMES.N</tag>
     49 	</item>
     50 	<item>
     51 	   <ruleref uri="#S"/>
     52 	   <tag>TELN=S.X;</tag>
     53         </item>
     54      </one-of>
     55    </rule>
     56 
     57    <rule id="NAMES">
     58      <one-of>
     59       <item>
     60 	Peter
     61 	<tag>N='Peter'</tag>
     62       </item>
     63       <item>
     64 	Wilson
     65         <tag>N='Wilson'</tag>
     66       </item>
     67       <item>
     68 	Jessica
     69         <tag>N='Jessica'</tag>
     70       </item>
     71       <item>
     72 	Janese
     73         <tag>N='Janese'</tag>
     74       </item>
     75       <item>
     76 	John Martinez
     77         <tag>N='John Martinez'</tag>
     78       </item>
     79       <item>
     80 	Jen Parker
     81         <tag>N='Jen Parker'</tag>
     82       </item>
     83       <item>
     84 	Jennifer
     85         <tag>N='Jennifer'</tag>
     86       </item>
     87       <item>
     88 	Elaine
     89         <tag>N='Elaine'</tag>
     90       </item>
     91       <item>
     92 	David
     93         <tag>N='David'</tag>
     94       </item>
     95      </one-of>
     96    </rule>
     97 
     98    <rule id="PLACES">
     99      <one-of>
    100       <item>office <tag>P='office'</tag>     </item>
    101       <item>	friends       <tag>P='friends'</tag>      </item>
    102       <item>	home        <tag>P='home'</tag> </item>
    103       <item>	mobile        <tag>P='mobile'</tag> </item>
    104      </one-of>
    105    </rule>
    106    
    107    <rule id="S">
    108       <item repeat="1-">
    109          <ruleref uri="#DIGIT"/>
    110          <tag>X=X?X:'';X=X+DIGIT.V;</tag>
    111       </item>
    112    </rule>
    113 
    114    <rule id="DIGIT">
    115       <one-of>
    116          <item>
    117             zero
    118             <tag>V='0'</tag>
    119          </item>
    120          <item>
    121             oh
    122             <tag>V='0'</tag>
    123          </item>
    124          <item>
    125             one
    126             <tag>V='1'</tag>
    127          </item>
    128          <item>
    129             two
    130             <tag>V='2'</tag>
    131          </item>
    132          <item>
    133             three
    134             <tag>V='3'</tag>
    135          </item>
    136          <item>
    137             four
    138             <tag>V='4'</tag>
    139          </item>
    140          <item>
    141             five
    142             <tag>V='5'</tag>
    143          </item>
    144          <item>
    145             six
    146             <tag>V='6'</tag>
    147          </item>
    148          <item>
    149             seven
    150             <tag>V='7'</tag>
    151          </item>
    152          <item>
    153             eight
    154             <tag>V='8'</tag>
    155          </item>
    156          <item>
    157             nine
    158             <tag>V='9'</tag>
    159          </item>
    160       </one-of>
    161    </rule>
    162 
    163 </grammar>
    164