| <?xml version="1.0" encoding="iso-8859-1"?> |
| <!DOCTYPE grammar PUBLIC "-//W3C//DTD GRAMMAR 1.0//EN" |
| "http://www.w3.org/TR/speech-grammar/grammar.dtd"> |
| <grammar version="1.0" xmlns="http://www.w3.org/2001/06/grammar" xml:lang="en-US" tag-format="semantics/1.0" |
| mode="voice" root="mydate"> |
| |
| <!-- |
| * Licensed to the Apache Software Foundation (ASF) under one or more |
| * contributor license agreements. See the NOTICE file distributed with |
| * this work for additional information regarding copyright ownership. |
| * The ASF licenses this file to You under the Apache License, Version 2.0 |
| * (the "License"); you may not use this file except in compliance with |
| * the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| --> |
| |
| <!-- |
| |
| This grammar accepts : month + day + [year] |
| Year is optional and Validate Date validation class should infer that |
| the current date if year is not specified |
| eg., |
| "January twentyfirst two thousand and fourth" |
| "January twentyfirst" |
| |
| Returns: MMDDYYYY in the first case. or |
| MMDD???? if year is not specified |
| |
| --> |
| |
| <rule id="mydate" scope="public"> |
| <item> |
| <one-of> |
| |
| |
| <!-- <item><ruleref uri="#day"/><tag><![CDATA[ $ = $day ; ]]></tag></item>--> |
| <item><ruleref uri="#day"/><ruleref uri="#yr"/><tag><![CDATA[ |
| $ = $day + $yr; |
| ]]></tag></item> |
| <item><ruleref uri="#day"/><tag><![CDATA[ |
| $ = $day + "????"; |
| ]]></tag></item> |
| |
| <item><ruleref uri="#day"/><ruleref uri="#of_yr"/><ruleref uri="#yr"/><tag><![CDATA[ |
| $ = $day + $yr; |
| ]]></tag></item> |
| <item><ruleref uri="#mo"/><ruleref uri="#common"/><ruleref uri="#yr"/><tag><![CDATA[ |
| $ = $mo + "??" + $yr; |
| ]]></tag></item> |
| <!-- <item><ruleref uri="#day"/><ruleref uri="#yr"/><tag><![CDATA[ |
| $ = $day + $yr; |
| ]]></tag></item>--> |
| <item><ruleref uri="#mo"/><ruleref uri="#of_yr"/><ruleref uri="#yr"/><tag><![CDATA[ |
| $ = $mo + "??" + $yr ; |
| ]]></tag></item> |
| |
| |
| <item><ruleref uri="#other"/><tag><![CDATA[ |
| $ = $other; |
| ]]></tag></item> |
| |
| </one-of> |
| </item> |
| </rule> |
| |
| <rule id="day"> |
| <one-of> |
| <item> |
| <item> |
| <one-of> |
| <item><ruleref uri="#days29"/> |
| <item repeat="0-1"> the </item><ruleref uri="#ordinal01to29"/> |
| </item> |
| <item> |
| <item repeat="0-1"> the </item><ruleref uri="#ordinal01to29"/> |
| <item repeat="0-1"> day </item> of <ruleref uri="#days29"/> |
| </item> |
| </one-of> |
| </item><tag><![CDATA[ |
| $=$days29 + $ordinal01to29; |
| |
| ]]></tag> |
| </item> |
| <item> |
| <item> |
| <one-of> |
| <item><ruleref uri="#days30"/> |
| <item repeat="0-1"> the </item><ruleref uri="#ordinal01to30"/> |
| </item> |
| <item> |
| <item repeat="0-1"> the </item><ruleref uri="#ordinal01to30"/> |
| <item repeat="0-1"> day </item> of <ruleref uri="#days30"/> |
| </item> |
| </one-of> |
| </item><tag><![CDATA[ |
| $=$days30 + $ordinal01to30; |
| |
| ]]></tag> |
| </item> |
| <item> |
| <item> |
| <one-of> |
| <item><ruleref uri="#days31"/> |
| <item repeat="0-1"> the </item><ruleref uri="#ordinal01to31"/> |
| </item> |
| <item> |
| <item repeat="0-1"> the </item><ruleref uri="#ordinal01to31"/> |
| <item repeat="0-1"> day </item> of <ruleref uri="#days31"/> |
| </item> |
| </one-of> |
| </item><tag><![CDATA[ |
| $=$days31 + $ordinal01to31; |
| |
| ]]></tag> |
| </item> |
| </one-of> |
| </rule> |
| |
| |
| <rule id="of_yr"> |
| <item> |
| <one-of> |
| <item> in </item> |
| <item> in the year </item> |
| <item> in the year of </item> |
| <item> the year of </item> |
| <item> the year </item> |
| <item> of </item> |
| <item><ruleref special="NULL"/></item> |
| </one-of> |
| </item> |
| </rule> |
| |
| <rule id="yr"> |
| <one-of> |
| <item><ruleref uri="#teens"/> hundred <tag><![CDATA[ $ = $teens + "00" ; |
| ]]></tag></item> |
| <item><ruleref uri="#teens"/> |
| <item> |
| <one-of> |
| <item><ruleref special="NULL"/></item> |
| <item> hundred |
| <item repeat="0-1"> and </item> |
| </item> |
| </one-of> |
| </item><ruleref uri="#twoDNum1To99"/><tag><![CDATA[ |
| $ = $teens + $twoDNum1To99; |
| ]]></tag> |
| </item> |
| <item> ninety <ruleref uri="#numbers1to9"/><tag><![CDATA[ |
| $ = "199" + $numbers1to9; |
| ]]></tag></item> |
| <item> two thousand |
| <item repeat="0-1"> and </item><ruleref uri="#twoDNum1To99"/><tag><![CDATA[ |
| $ = "20" + $twoDNum1To99; |
| ]]></tag> |
| </item> |
| <item> two thousand |
| <item> |
| <one-of> |
| <item> zero </item> |
| <item> oh </item> |
| <item> nil </item> |
| <item> null </item> |
| </one-of> |
| </item><ruleref uri="#numbers1to9"/><tag><![CDATA[ $ = "20" + "0" + $numbers1to9; |
| ]]></tag> |
| </item> |
| <item> two thousand <tag><![CDATA[ |
| $ = "2000"; |
| ]]></tag></item> |
| <item><ruleref uri="#twoDNum1To99"/><ruleref uri="#numbers01to99"/><tag><![CDATA[ |
| $ = $twoDNum1To99 + $numbers01to99; |
| ]]></tag></item> |
| </one-of> |
| </rule> |
| |
| |
| <rule id="days29"> february <tag><![CDATA[$="02"; ]]></tag></rule> |
| |
| <rule id="days30"> |
| <one-of> |
| <item> april <tag><![CDATA[$="04"; ]]></tag></item> |
| <item> june <tag><![CDATA[$="06"; ]]></tag></item> |
| <item> september <tag><![CDATA[$="09";]]></tag></item> |
| <item> november <tag><![CDATA[$="11"; ]]></tag></item> |
| </one-of> |
| </rule> |
| |
| <rule id="days31"> |
| <one-of> |
| <item> january <tag><![CDATA[$="01";]]></tag></item> |
| <item> march <tag><![CDATA[$="03";]]></tag></item> |
| <item> may <tag><![CDATA[$="05"; ]]></tag></item> |
| <item> july <tag><![CDATA[$="07"; ]]></tag></item> |
| <item> august <tag><![CDATA[$="08"; ]]></tag></item> |
| <item> october <tag><![CDATA[$="10";]]></tag></item> |
| <item> december <tag><![CDATA[$="12"; ]]></tag></item> |
| </one-of> |
| </rule> |
| |
| <rule id="mo"> |
| <one-of> |
| <item><ruleref uri="#days29"/><tag><![CDATA[ $=$days29 ; ]]></tag></item> |
| <item><ruleref uri="#days30"/><tag><![CDATA[ $=$days30 ; ]]></tag></item> |
| <item><ruleref uri="#days31"/><tag><![CDATA[ $=$days31 ; ]]></tag></item> |
| </one-of> |
| </rule> |
| |
| <rule id="other"> |
| <item> |
| <one-of> |
| <item> today <tag><![CDATA[$ = "today";]]></tag></item> |
| <item> yesterday <tag><![CDATA[$ = "yesterday";]]></tag></item> |
| <item> tomorrow <tag><![CDATA[$ = "tomorrow";]]></tag></item> |
| </one-of> |
| </item> |
| </rule> |
| |
| <rule id="ordinal1to9"> |
| <one-of> |
| <item> first <tag><![CDATA[ $="1"; ]]></tag></item> |
| <item><ruleref uri="#ordinal02to9"/><tag><![CDATA[ $=$ordinal02to9; ]]></tag></item> |
| </one-of> |
| </rule> |
| |
| |
| <rule id="ordinal01to19"> |
| <one-of> |
| <item> first <tag><![CDATA[ $="01";]]></tag></item> |
| <item><ruleref uri="#ordinal02to19"/><tag><![CDATA[ $=$ordinal02to19; ]]></tag></item> |
| </one-of> |
| </rule> |
| |
| <rule id="ordinal02to19"> |
| <one-of> |
| <item><ruleref uri="#ordinal02to9"/><tag><![CDATA[ $="0" + $ordinal02to9; ]]></tag></item> |
| <item><ruleref uri="#ordinal10to19"/><tag><![CDATA[ $=$ordinal10to19;]]></tag></item> |
| </one-of> |
| </rule> |
| |
| <rule id="ordinal01to29"> |
| <one-of> |
| <item><ruleref uri="#ordinal01to19"/><tag><![CDATA[ $=$ordinal01to19; ]]></tag></item> |
| <item> twentieth <tag><![CDATA[ $="20"; ]]></tag></item> |
| <item> twenty <ruleref uri="#ordinal1to9"/><tag><![CDATA[ $="2" + $ordinal1to9; ]]></tag></item> |
| </one-of> |
| </rule> |
| |
| <rule id="ordinal01to30"> |
| <one-of> |
| <item><ruleref uri="#ordinal01to29"/><tag><![CDATA[ $=$ordinal01to29; ]]></tag></item> |
| <item> thirtieth <tag><![CDATA[ $="30";]]></tag></item> |
| </one-of> |
| </rule> |
| |
| <rule id="ordinal02to9"> |
| <one-of> |
| <item> second <tag><![CDATA[ $="2"; ]]></tag></item> |
| <item> two <tag><![CDATA[ $="2";]]></tag></item> |
| <item> third <tag><![CDATA[ $="3"; ]]></tag></item> |
| <item> three <tag><![CDATA[ $="3"; ]]></tag></item> |
| <item> fourth <tag><![CDATA[ $="4"; ]]></tag></item> |
| <item> four <tag><![CDATA[ $="4"; ]]></tag></item> |
| <item> fifth <tag><![CDATA[ $="5"; ]]></tag></item> |
| <item> five <tag><![CDATA[ $="5"; ]]></tag></item> |
| <item> sixth <tag><![CDATA[ $="6"; ]]></tag></item> |
| <item> six <tag><![CDATA[ $="6"; ]]></tag></item> |
| <item> seventh <tag><![CDATA[ $="7"; ]]></tag></item> |
| <item> seven<tag><![CDATA[ $="7"; ]]></tag></item> |
| <item> eighth <tag><![CDATA[ $="8"; ]]></tag></item> |
| <item> eight <tag><![CDATA[ $="8"; ]]></tag></item> |
| <item> ninth <tag><![CDATA[ $="9";]]></tag></item> |
| <item> nine <tag><![CDATA[ $="9";]]></tag></item> |
| </one-of> |
| </rule> |
| |
| <rule id="ordinal10to19"> |
| <one-of> |
| <item> tenth <tag><![CDATA[ $="10"; ]]></tag></item> |
| <item> eleventh <tag><![CDATA[ $="11"; ]]></tag></item> |
| <item> eleven <tag><![CDATA[ $="11"; ]]></tag></item> |
| <item> twelfth <tag><![CDATA[ $="12"; ]]></tag></item> |
| <item> twelve <tag><![CDATA[ $="12"; ]]></tag></item> |
| <item> thirteenth <tag><![CDATA[ $="13"; ]]></tag></item> |
| <item> thirteen <tag><![CDATA[ $="13"; ]]></tag></item> |
| <item> fourteenth <tag><![CDATA[ $="14"; ]]></tag></item> |
| <item> fourteen <tag><![CDATA[ $="14"; ]]></tag></item> |
| <item> fifteenth <tag><![CDATA[ $="15"; ]]></tag></item> |
| <item> fifteen <tag><![CDATA[ $="15"; ]]></tag></item> |
| <item> sixteenth <tag><![CDATA[ $="16"; ]]></tag></item> |
| <item> sixteen <tag><![CDATA[ $="16"; ]]></tag></item> |
| <item> seventeenth <tag><![CDATA[ $="17"; ]]></tag></item> |
| <item> seventeen <tag><![CDATA[ $="17"; ]]></tag></item> |
| <item> eighteenth <tag><![CDATA[ $="18";]]></tag></item> |
| <item> eighteen <tag><![CDATA[ $="18";]]></tag></item> |
| <item> nineteenth <tag><![CDATA[ $="19"; ]]></tag></item> |
| <item> nineteen <tag><![CDATA[ $="19"; ]]></tag></item> |
| </one-of> |
| </rule> |
| |
| |
| <rule id="ordinal01to31"> |
| <one-of> |
| <item><ruleref uri="#ordinal01to30"/><tag><![CDATA[ $=$ordinal01to30; ]]></tag></item> |
| <item> thirty first <tag><![CDATA[ $="31"; ]]></tag></item> |
| </one-of> |
| </rule> |
| |
| <rule id="numbers1to9"> |
| <one-of> |
| <item> one <tag><![CDATA[ $="1"; ]]></tag></item> |
| <item><ruleref uri="#numbers2to9"/><tag><![CDATA[ $=$numbers2to9; ]]></tag></item> |
| </one-of> |
| </rule> |
| |
| <rule id="numbers2to9"> |
| <one-of> |
| <item> two <tag><![CDATA[ $="2"; ]]></tag></item> |
| <item> three <tag><![CDATA[ $="3"; ]]></tag></item> |
| <item> four <tag><![CDATA[ $="4"; ]]></tag></item> |
| <item> five <tag><![CDATA[ $="5"; ]]></tag></item> |
| <item> six <tag><![CDATA[ $="6"; ]]></tag></item> |
| <item> seven <tag><![CDATA[ $="7"; ]]></tag></item> |
| <item> eight <tag><![CDATA[ $="8"; ]]></tag></item> |
| <item> nine <tag><![CDATA[ $="9"; ]]></tag></item> |
| </one-of> |
| </rule> |
| |
| <rule id="teens"> |
| <one-of> |
| <item> eleven <tag><![CDATA[ $="11"; ]]></tag></item> |
| <item> twelve <tag><![CDATA[ $="12"; ]]></tag></item> |
| <item> thirteen <tag><![CDATA[ $="13"; ]]></tag></item> |
| <item> fourteen <tag><![CDATA[ $="14"; ]]></tag></item> |
| <item> fifteen <tag><![CDATA[ $="15"; ]]></tag></item> |
| <item> sixteen <tag><![CDATA[ $="16"; ]]></tag></item> |
| <item> seventeen <tag><![CDATA[ $="17"; ]]></tag></item> |
| <item> eighteen <tag><![CDATA[ $="18"; ]]></tag></item> |
| <item> nineteen <tag><![CDATA[ $="19"; ]]></tag></item> |
| </one-of> |
| </rule> |
| |
| <rule id="twoDNum1To99"> |
| <one-of> |
| <item><ruleref uri="#tens20to90"/><ruleref uri="#numbers1to9"/><tag><![CDATA[ $=$tens20to90 + $numbers1to9; ]]></tag></item> |
| <item><ruleref uri="#tens"/><tag><![CDATA[ $=$tens + "0"; ]]></tag></item> |
| <item><ruleref uri="#teens"/></item> |
| <item><ruleref uri="#numbers1to9"/><tag><![CDATA[ $="0" + $numbers1to9; ]]></tag></item> |
| </one-of> |
| |
| </rule> |
| |
| |
| <rule id="numbers01to99"> |
| <one-of> |
| <item><ruleref uri="#numbers02to99"/></item> |
| <item> |
| <item> |
| <one-of> |
| <item> zero </item> |
| <item> oh </item> |
| <item> nil </item> |
| <item> null </item> |
| </one-of> |
| </item> one <tag><![CDATA[ $="01"; ]]></tag> |
| </item> |
| </one-of> |
| </rule> |
| |
| <rule id="numbers02to99"> |
| <one-of> |
| <item> |
| <item> |
| <one-of> |
| <item> zero </item> |
| <item> oh </item> |
| <item> nil </item> |
| <item> null </item> |
| </one-of> |
| </item><ruleref uri="#numbers2to9"/><tag><![CDATA[ $="0" + $numbers2to9; ]]></tag> |
| </item> |
| <item><ruleref uri="#teens"/></item> |
| <item><ruleref uri="#tens"/><tag><![CDATA[ $=$tens + "0"; ]]></tag></item> |
| <item><ruleref uri="#tens"/><ruleref uri="#numbers1to9"/><tag><![CDATA[ $=$tens + $numbers1to9; ]]></tag></item> |
| </one-of> |
| </rule> |
| |
| <rule id="tens20to90"> |
| <one-of> |
| <item> twenty <tag><![CDATA[ $="2"; ]]></tag></item> |
| <item> thirty <tag><![CDATA[ $="3"; ]]></tag></item> |
| <item> forty <tag><![CDATA[ $="4"; ]]></tag></item> |
| <item> fifty <tag><![CDATA[ $="5"; ]]></tag></item> |
| <item> sixty <tag><![CDATA[ $="6"; ]]></tag></item> |
| <item> seventy <tag><![CDATA[ $="7"; ]]></tag></item> |
| <item> eighty <tag><![CDATA[ $="8"; ]]></tag></item> |
| <item> ninety <tag><![CDATA[ $="9"; ]]></tag></item> |
| </one-of> |
| </rule> |
| |
| <rule id="tens"> |
| <one-of> |
| <item> ten <tag><![CDATA[ $="1"; ]]></tag></item> |
| <item> twenty <tag><![CDATA[ $="2"; ]]></tag></item> |
| <item> thirty <tag><![CDATA[ $="3"; ]]></tag></item> |
| <item> forty <tag><![CDATA[ $="4"; ]]></tag></item> |
| <item> fifty <tag><![CDATA[ $="5"; ]]></tag></item> |
| <item> sixty <tag><![CDATA[ $="6"; ]]></tag></item> |
| <item> seventy <tag><![CDATA[ $="7"; ]]></tag></item> |
| <item> eighty <tag><![CDATA[ $="8"; ]]></tag></item> |
| <item> ninety <tag><![CDATA[ $="9"; ]]></tag></item> |
| </one-of> |
| </rule> |
| |
| <rule id="mo_of"> |
| <item> |
| <one-of> |
| <item> in </item> |
| <item> in the month </item> |
| <item> in the month of </item> |
| <item> the month of </item> |
| <item> the month </item> |
| <item><ruleref special="NULL"/></item> |
| </one-of> |
| </item> |
| </rule> |
| |
| <rule id="yr_of"> |
| <item> |
| <one-of> |
| <item> in </item> |
| <item> in the year </item> |
| <item> in the year of </item> |
| <item> the year of </item> |
| <item> the year </item> |
| <item><ruleref special="NULL"/></item> |
| </one-of> |
| </item> |
| </rule> |
| |
| <rule id="common"> |
| <item> |
| <one-of> |
| <item> in </item> |
| <item> of </item> |
| <item><ruleref special="NULL"/></item> |
| </one-of> |
| </item> |
| </rule> |
| </grammar> |
| |