Larson Technical Services: Voice Technology Consulting

Exercise 7.2

Write the following grammars using the ABNF grammar notation for your national language:

A. Months of the year. (In English, these include “January,” “February, etc” .)


 <grammar root= "month">
     <rule id = "month">
          <one-of>
               <item>January</item>
               <item>February</item>
               <item>March</item>
               <item>April</item>
               <item>May</item>
               <item>June</item>
               <item>July</item>
               <item>August</item>
               <item>September</item>
               <item>October</item>
               <item>November</item>
               <item>December</item>
          </one-of>
     </rule>
</grammar>

B. Days in a month. (In English, these include “one,” “two,” …, “thirty-one.”)


 <grammar root = "day">
     <rule id = "day">
          <one-of>
               <relref id = "ones" </relref>
               <relref id = "tens" </relref>
               <relref id = "twenties" </relref>
               <relref id = "thirties" </relref>
          </one-of>
     </rule>

     <rule id = "ones">
          <one-of>
               <item>one</item>
               <item>two</item>
               <item>three</item>
               <item>four</item>
               <item>five</item>
               <item>six</item>
               <item>seven</item>
               <item>eight</item>
               <item>none</item>
          </one-of>
     </rule>

     <rule id = "tens">
          <one-of>
               <item>ten</item>
               <item>eleven</item>
               <item>twelve</item>
               <item>thirteen</item>
               <item>fourtreen</item>
               <item>fifteen</item>
               <item>sixteen</item>
               <item>seventeen</item>
               <item>eighteen</item>
               <item>nineteen</item>
          </one-of>
     </rule>

     <rule id = "twenties">
          <one-of>
               <item>twenty</item>
               <item>twenty <relref id = "ones" </relref> </item>
          </one-of>
     </rule>

     <rule id = "thirties">
          <one-of>
               <item>thirty</item>
               <item>twenty one </item>
          </one-of>
          </rule>

C. Years. (In English, these include “nineteen ninety-nine,” “two thousand,” “two thousand and one, etc” .)


<grammar root = "year">
     <rule id = "day"> <rule id = "ones">
          <one-of>
               <item>one</item>
               <item>two</item>
               <item>three</item>
               <item>four</item>
               <item>five</item>
               <item>six</item>
               <item>seven</item>
               <item>eight</item>
               <item>none</item>
          </one-of>
     </rule>

     <rule id = "tens">
          <one-of>
               <item>ten</item>
               <item>eleven</item>
               <item>twelve</item>
               <item>thirteen</item>
               <item>fourtreen</item>
               <item>fifteen</item>
               <item>sixteen</item>
               <item>seventeen</item>
               <item>eighteen</item>
               <item>nineteen</item>
          </one-of>
     </rule>

     <rule id = "twenties">
          <one-of>
               <item>twenty</item
               <item>twenty <relref id = "ones" </relref> </item>
          </one-of>
     </rule>
     <rule id = "thirties">
          <one-of>
               <item>thirty</item>
               <item>twenty <relref id = "ones" </relref>  </item>
          </one-of>
     </rule>

     <rule id = "fourties">
          <one-of>
               <item>fourty</item>
               <item>fourty <relref id = "ones" </relref>  </item>
          </one-of>
     </rule>

     <rule id = "fifties">
          <one-of>
               <item>fifty</item>
               <item>fifty <relref id = "ones" </relref>  </item>
          </one-of>
     </rule>

     <rule id = "sixties">
          <one-of>
               <item>sixty</item>
               <item>sixty <relref id = "ones" </relref>  </item>
          </one-of>
     </rule>

     <rule id = "seventies">
          <one-of>
               <item>seventy</item>
               <item>seventy  <relref id = "ones" </relref>  </item>
          </one-of>
     </rule>

     <rule id = "eighties">
          <one-of>
               <item>eighty</item>
               <item>eighty <relref id = "ones" </relref>  </item>
          </one-of>
     </rule>

     <rule id = "nineties">
          <one-of>
               <item>ninety</item>
               <item>ninety <relref id = "ones" </relref>  </item>
          </one-of>
     </rule>

     <rule id = "hundreds">
          <one-of>
               <item>hundred</item>
               <item> <relref id = "ones" </relref>  </item>
               <item> <relref id = "tens" </relref>  </item>
               <item> <relref id = "thirties" </relref>  </item>
               <item> <relref id = "fourties" </relref>  </item>
               <item> <relref id = "fifties" </relref>  </item>
               <item> <relref id = "sixties" </relref>  </item>
               <item> <relref id = "seventies" </relref>  </item>
               <item> <relref id = "eighties" </relref>  </item>
               <item> <relref id = "nineties" </relref>  </item>
          </one-of>
     </rule>

     <rule id = "years">
          <one-of>
               <item>nineteen</item>
               <item>nineteen<relref id = "hundreds" </relref>  </item>
               <item>two thousand <relref id = "hundreds" </relref>  </item>
          </one-of>
     </rule>
</grammar>

D. Dates. The caller may say the values for month, day and year in any order


<grammar root = "date"> 

     <rule id = "mdy">
          <relref id = "month" </relref>
          <relref id = "day" </relref>
          <relref id = "year </relref>
     </rule> 

     <rule id = "dmy">
          <relref id = "day" </relref>
          <relref id = "month" </relref>
          <relref id = "year </relref>
     </rule>

     <rule id = "date">
          <one-of>
               <relref id = "mdy" </relref>
               <relref id = "dmy" </relref>
          </one-of>
     </rule>
</grammar>

Return to the Instructor’s Page

Comments are off for this post