You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
514 lines
17 KiB
514 lines
17 KiB
|
|
<GRAMMAR LANGID="409">
|
|
|
|
<DEFINE>
|
|
<ID NAME="BILLIONS" VAL="1"/>
|
|
<ID NAME="MILLIONS" VAL="2"/>
|
|
<ID NAME="THOUSANDS" VAL="3"/>
|
|
<ID NAME="HUNDREDS" VAL="4"/>
|
|
<ID NAME="TENS" VAL="5"/>
|
|
<ID NAME="ONES" VAL="6"/>
|
|
<ID NAME="TEENS" VAL="200"/>
|
|
<ID NAME="NEGATIVE" VAL="7"/>
|
|
<ID NAME="MILLBILL" VAL="8"/>
|
|
<ID NAME="DIGIT" VAL="9"/>
|
|
<ID NAME="TWODIGIT" VAL="10"/>
|
|
<ID NAME="FP_PART" VAL="11"/>
|
|
<ID NAME="ZERO" VAL="12"/>
|
|
<ID NAME="POINT_ZERO" VAL="13"/>
|
|
<ID NAME="DENOMINATOR" VAL="15"/>
|
|
<ID NAME="WHOLE" VAL="16"/>
|
|
<ID NAME="ONEDIGIT" VAL="17"/>
|
|
<ID NAME="GRID_INTEGER_99" VAL="101"/>
|
|
<ID NAME="GRID_INTEGER_999" VAL="102"/>
|
|
<ID NAME="GRID_INTEGER_MILLBILL" VAL="103"/>
|
|
<ID NAME="GRID_INTEGER_STANDALONE" VAL="104"/>
|
|
<ID NAME="GRID_INTEGER" VAL="105"/>
|
|
<ID NAME="GRID_INTEGER_NONNEG" VAL="106"/>
|
|
<ID NAME="GRID_DIGIT_NUMBER" VAL="107"/>
|
|
<ID NAME="GRID_FP_NUMBER" VAL="108"/>
|
|
<ID NAME="GRID_FP_NUMBER_NONNEG" VAL="109"/>
|
|
<ID NAME="GRID_NUMBER" VAL="110"/>
|
|
</DEFINE>
|
|
|
|
|
|
<!--
|
|
GRID_NUMBER
|
|
Includes all kinds of numbers, negative or positive, interger or decimal.
|
|
-->
|
|
|
|
<RULE NAME="GRID_NUMBER" ID="GRID_NUMBER" TOPLEVEL="ACTIVE" EXPORT="0">
|
|
<LN>
|
|
<P WEIGHT="1000.01">zhoulotskunosprok</P>
|
|
<P WEIGHT="1.01">Force Num
|
|
<O>
|
|
<RULEREF NAME="NEGATIVE" PROPNAME="NEGATIVE" PROPID="NEGATIVE"/>
|
|
</O>
|
|
<L>
|
|
<RULEREF NAME="GRID_INTEGER_STANDALONE" PROPNAME="GRID_INTEGER_STANDALONE" PROPID="GRID_INTEGER_STANDALONE"/>
|
|
<RULEREF NAME="fp_number_nonneg" PROPNAME="GRID_FP_NUMBER" PROPID="GRID_FP_NUMBER"/>
|
|
</L>
|
|
</P>
|
|
</LN>
|
|
</RULE>
|
|
|
|
<!--
|
|
INTEGER_STANDALONE
|
|
A INTEGER_STANDALONE can be in the range (-1e12, 1e12) and will always be
|
|
called as a toplevel rule.
|
|
This rule is not referenced by any other rules.
|
|
-->
|
|
<RULE NAME="GRID_INTEGER_STANDALONE" ID="GRID_INTEGER_STANDALONE" TOPLEVEL="INACTIVE" EXPORT="1">
|
|
<L>
|
|
<P>
|
|
<RULEREF NAME="GRID_INTEGER_MILLBILL" PROPNAME="GRID_INTEGER_MILLBILL" PROPID="GRID_INTEGER_MILLBILL"/>
|
|
</P>
|
|
<P>
|
|
<RULEREF NAME="integer_base_nonneg"/>
|
|
</P>
|
|
</L>
|
|
</RULE>
|
|
|
|
<!--
|
|
INTEGER_MILLBILL
|
|
Numbers for which the word "million" or "billion" should be displayed
|
|
-->
|
|
<RULE NAME="GRID_INTEGER_MILLBILL" ID="GRID_INTEGER_MILLBILL" TOPLEVEL="INACTIVE" EXPORT="1">
|
|
<L>
|
|
<P>
|
|
<RULEREF NAME="GRID_INTEGER_99" PROPNAME="GRID_INTEGER_99" PROPID="GRID_INTEGER_99"/>
|
|
</P>
|
|
<P>
|
|
<RULEREF NAME="GRID_FP_NUMBER_NONNEG" PROPNAME="GRID_FP_NUMBER_NONNEG" PROPID="GRID_FP_NUMBER_NONNEG"/>
|
|
</P>
|
|
</L>
|
|
<LN PROPNAME="MILLBILL" PROPID="MILLBILL">
|
|
<PN VAL="MILLIONS" VALSTR="million">million</PN>
|
|
<PN VAL="BILLIONS" VALSTR="billion">billion</PN>
|
|
</LN>
|
|
</RULE>
|
|
|
|
<!--
|
|
INTEGER_99
|
|
Numbers in [0, 100)
|
|
Toplevel inactive but can be imported
|
|
-->
|
|
<RULE NAME="GRID_INTEGER_99" ID="GRID_INTEGER_99" TOPLEVEL="INACTIVE" EXPORT="1">
|
|
<RULEREF NAME="cardinal_99" PROPNAME="ONES" PROPID="ONES"/>
|
|
</RULE>
|
|
<!--
|
|
INTEGER_999
|
|
Numbers in [0, 1000)
|
|
Toplevel inactive but can be imported
|
|
-->
|
|
<RULE NAME="GRID_INTEGER_999" ID="GRID_INTEGER_999" TOPLEVEL="INACTIVE" EXPORT="1">
|
|
<RULEREF NAME="cardinal_999" PROPNAME="ONES" PROPID="ONES"/>
|
|
</RULE>
|
|
|
|
<!--
|
|
integer_base_nonneg
|
|
Same as above except nonnegative
|
|
-->
|
|
<RULE NAME="integer_base_nonneg">
|
|
<L>
|
|
<P>
|
|
<RULEREF NAME="cardinal"/>
|
|
</P>
|
|
<P>
|
|
<RULEREF NAME="GRID_DIGIT_NUMBER" PROPNAME="GRID_DIGIT_NUMBER" PROPID="GRID_DIGIT_NUMBER"/>
|
|
</P>
|
|
</L>
|
|
</RULE>
|
|
|
|
<!--
|
|
cardinal
|
|
A cardinal is defined here as a number in [0, 1e12), properly
|
|
formed (not spoken digit by digit)
|
|
-->
|
|
<RULE NAME="cardinal">
|
|
<L>
|
|
<P>
|
|
<L>
|
|
<P>
|
|
<RULEREF NAME="big_part"/>
|
|
</P>
|
|
</L>
|
|
|
|
<O>
|
|
<O>
|
|
and
|
|
</O>
|
|
<P>
|
|
<!-- cardinal_999 part optional if the big_part is present -->
|
|
<RULEREF NAME="cardinal_999" PROPNAME="ONES" PROPID="ONES" VAL="1"/>
|
|
</P>
|
|
</O>
|
|
</P>
|
|
<P>
|
|
<P>
|
|
<RULEREF NAME="cardinal_99_nonzero" PROPNAME="HUNDREDS" PROPID="HUNDREDS" VAL="1"/>
|
|
</P>
|
|
<P>
|
|
hundred
|
|
</P>
|
|
<O>
|
|
<O>
|
|
and
|
|
</O>
|
|
<P>
|
|
<RULEREF NAME="cardinal_99_nonzero" PROPNAME="ONES" PROPID="ONES" VAL="1"/>
|
|
</P>
|
|
</O>
|
|
</P>
|
|
<P>
|
|
<!-- cardinal_999 part mandatory if the big_part is not present.
|
|
In this case, the cardinal_999 part must be at least 20 -->
|
|
<RULEREF NAME="cardinal_999" PROPNAME="ONES" PROPID="ONES" VAL="1"/>
|
|
</P>
|
|
</L>
|
|
</RULE>
|
|
|
|
|
|
<!--
|
|
big_part
|
|
A big_part is the part of a spoken number that is divisible by 1000. It
|
|
has to be in the range (-1e12, 1e12).
|
|
-->
|
|
<RULE NAME="big_part">
|
|
<L>
|
|
<P>
|
|
<RULEREF NAME="cardinal_999" PROPNAME="BILLIONS" PROPID="BILLIONS"/>
|
|
<P> billion </P>
|
|
<!-- billions are present, so millions and thousands are optional -->
|
|
<O>
|
|
<RULEREF NAME="cardinal_999" PROPNAME="MILLIONS" PROPID="MILLIONS"/>
|
|
<P> million </P>
|
|
</O>
|
|
<O>
|
|
<RULEREF NAME="cardinal_999" PROPNAME="THOUSANDS" PROPID="THOUSANDS"/>
|
|
<P> thousand </P>
|
|
</O>
|
|
</P>
|
|
<P>
|
|
<RULEREF NAME="cardinal_999" PROPNAME="MILLIONS" PROPID="MILLIONS"/>
|
|
<P> million </P>
|
|
<!-- millions are present, so thousands are optional -->
|
|
<O>
|
|
<RULEREF NAME="cardinal_999" PROPNAME="THOUSANDS" PROPID="THOUSANDS"/>
|
|
<P> thousand </P>
|
|
</O>
|
|
</P>
|
|
<P>
|
|
<!-- billions and millions not present, so thousands are mandatory -->
|
|
<RULEREF NAME="cardinal_999" PROPNAME="THOUSANDS" PROPID="THOUSANDS"/>
|
|
<P> thousand </P>
|
|
</P>
|
|
</L>
|
|
</RULE>
|
|
|
|
|
|
<!--
|
|
cardinal_999
|
|
This is defined as a number in [0,1000).
|
|
-->
|
|
<RULE NAME="cardinal_999">
|
|
<L>
|
|
<P PROPNAME="ZERO" PROPID="ZERO" VAL="0">
|
|
zero
|
|
</P>
|
|
<P>
|
|
<!-- A number between 1 and 19 -->
|
|
<RULEREF NAME="onesfrag" PROPNAME="ONES" VAL="1"/>
|
|
</P>
|
|
<P>
|
|
<!-- A "tens" number (20, 30,...) -->
|
|
<RULEREF NAME="tensfrag" PROPNAME="TENS" VAL="10"/>
|
|
<O>
|
|
<!-- Can be followed by a nonzero digit -->
|
|
<RULEREF NAME="digit_nonzero" PROPNAME="ONES" VAL="1"/>
|
|
</O>
|
|
</P>
|
|
<P>
|
|
<!-- A number at least 100 -->
|
|
<RULEREF NAME="hundredsfrag" PROPNAME="HUNDREDS" VAL="100"/>
|
|
<!-- optionally followed by tens and ones places -->
|
|
<O>
|
|
<L>
|
|
<P>
|
|
<!-- e.g. six hundred thirteen -->
|
|
<!-- Note that this case is not covered by the later case -->
|
|
<RULEREF NAME="onesfrag" PROPNAME="ONES" VAL="1"/>
|
|
</P>
|
|
<P>
|
|
<!-- e.g. six hundred thirty two -->
|
|
<RULEREF NAME="tensfrag" PROPNAME="TENS" VAL="10"/>
|
|
<O>
|
|
<!-- ones place optional -->
|
|
<RULEREF NAME="digit_nonzero" PROPNAME="ONES" VAL="1"/>
|
|
</O>
|
|
</P>
|
|
</L>
|
|
</O>
|
|
</P>
|
|
</L>
|
|
</RULE>
|
|
|
|
|
|
<!--
|
|
cardinal_99
|
|
Defined as any integer in [0,100)
|
|
-->
|
|
<RULE NAME="cardinal_99">
|
|
<L>
|
|
<P>
|
|
<RULEREF NAME="cardinal_99_nonzero"/>
|
|
</P>
|
|
<P>
|
|
<RULEREF NAME="zero"/>
|
|
</P>
|
|
</L>
|
|
</RULE>
|
|
|
|
<RULE NAME="cardinal_99_nonzero">
|
|
<L>
|
|
<P>
|
|
<RULEREF NAME="tensfrag" PROPNAME="TENS" VAL="10"/>
|
|
<O><RULEREF NAME="digit_nonzero" PROPNAME="ONES" VAL="1"/></O>
|
|
</P>
|
|
<P> <RULEREF NAME="onesfrag" PROPNAME="ONES" VAL="1"/> </P>
|
|
</L>
|
|
</RULE>
|
|
|
|
<RULE NAME="NEGATIVE">
|
|
<L>
|
|
<P>
|
|
negative
|
|
</P>
|
|
<P>
|
|
minus
|
|
</P>
|
|
</L>
|
|
</RULE>
|
|
|
|
<RULE NAME="twodigit">
|
|
<L>
|
|
<P>
|
|
<P>
|
|
<RULEREF NAME="tensfrag" PROPNAME="TENS" PROPID="TENS" VAL="10"/>
|
|
</P>
|
|
<O>
|
|
<RULEREF NAME="digit_nonzero" PROPNAME="ONES" PROPID="ONES" VAL="1"/>
|
|
</O>
|
|
</P>
|
|
<P>
|
|
<RULEREF NAME="onesfrag_teens" PROPNAME="TEENS" PROPID="TEENS" VAL="1"/>
|
|
</P>
|
|
</L>
|
|
</RULE>
|
|
|
|
|
|
<RULE NAME="hundredsfrag">
|
|
<L>
|
|
<LN PROPNAME="HUNDREDS" PROPID="HUNDREDS">
|
|
<PN VAL="1" VALSTR="1">a</PN>
|
|
</LN>
|
|
<P>
|
|
<RULEREF NAME="digit_nonzero"/>
|
|
</P>
|
|
</L>
|
|
<P>
|
|
hundred ?and
|
|
</P>
|
|
</RULE>
|
|
|
|
<RULE NAME="tensfrag">
|
|
<LN PROPNAME="TENS" PROPID="TENS">
|
|
<PN VAL="2" VALSTR="2">twenty</PN>
|
|
<PN VAL="3" VALSTR="3">thirty</PN>
|
|
<PN VAL="4" VALSTR="4">forty</PN>
|
|
<PN VAL="5" VALSTR="5">fifty</PN>
|
|
<PN VAL="6" VALSTR="6">sixty</PN>
|
|
<PN VAL="7" VALSTR="7">seventy</PN>
|
|
<PN VAL="8" VALSTR="8">eighty</PN>
|
|
<PN VAL="9" VALSTR="9">ninety</PN>
|
|
</LN>
|
|
</RULE>
|
|
|
|
<RULE NAME="onesfrag">
|
|
<L>
|
|
<P>
|
|
<RULEREF NAME="digit_nonzero"/>
|
|
</P>
|
|
<P>
|
|
<RULEREF NAME="onesfrag_teens"/>
|
|
</P>
|
|
</L>
|
|
</RULE>
|
|
|
|
<RULE NAME="onesfrag_teens">
|
|
<LN PROPNAME="ONES" PROPID="ONES">
|
|
<PN VAL="10" VALSTR="10">ten</PN>
|
|
<PN VAL="11" VALSTR="11">eleven</PN>
|
|
<PN VAL="12" VALSTR="12">twelve</PN>
|
|
<PN VAL="13" VALSTR="13">thirteen</PN>
|
|
<PN VAL="14" VALSTR="14">fourteen</PN>
|
|
<PN VAL="15" VALSTR="15">fifteen</PN>
|
|
<PN VAL="16" VALSTR="16">sixteen</PN>
|
|
<PN VAL="17" VALSTR="17">seventeen</PN>
|
|
<PN VAL="18" VALSTR="18">eighteen</PN>
|
|
<PN VAL="19" VALSTR="19">nineteen</PN>
|
|
</LN>
|
|
</RULE>
|
|
|
|
<RULE NAME="onesfrag_or_zero">
|
|
<L>
|
|
<P>
|
|
<RULEREF NAME="zero"/>
|
|
</P>
|
|
<P>
|
|
<RULEREF NAME="onesfrag"/>
|
|
</P>
|
|
</L>
|
|
</RULE>
|
|
|
|
<RULE NAME="digit_nonzero_or_one">
|
|
<LN PROPNAME="DIGIT" PROPID="DIGIT">
|
|
<PN VAL="2" VALSTR="2">two</PN>
|
|
<PN VAL="3" VALSTR="3">three</PN>
|
|
<PN VAL="4" VALSTR="4">four</PN>
|
|
<PN VAL="5" VALSTR="5">five</PN>
|
|
<PN VAL="6" VALSTR="6">six</PN>
|
|
<PN VAL="7" VALSTR="7">seven</PN>
|
|
<PN VAL="8" VALSTR="8">eight</PN>
|
|
<PN VAL="9" VALSTR="9">nine</PN>
|
|
</LN>
|
|
</RULE>
|
|
|
|
<RULE NAME="digit_nonzero">
|
|
<L>
|
|
<LN PROPNAME="DIGIT" PROPID="DIGIT">
|
|
<PN VAL="1" VALSTR="1">one</PN>
|
|
</LN>
|
|
<P>
|
|
<RULEREF NAME="digit_nonzero_or_one"/>
|
|
</P>
|
|
</L>
|
|
</RULE>
|
|
|
|
<RULE NAME="digit">
|
|
<L>
|
|
<LN PROPNAME="DIGIT" PROPID="DIGIT">
|
|
<PN VAL="0" VALSTR="0">zero</PN>
|
|
<PN VAL="0" VALSTR="0">oh</PN>
|
|
</LN>
|
|
<P>
|
|
<RULEREF NAME="digit_nonzero"/>
|
|
</P>
|
|
</L>
|
|
</RULE>
|
|
|
|
<RULE NAME="zero">
|
|
<LN PROPNAME="ONES" PROPID="ONES">
|
|
<PN VAL="0" VALSTR="0">zero</PN>
|
|
</LN>
|
|
</RULE>
|
|
|
|
<!--
|
|
DIGIT_NUMBER
|
|
Integers in (0, 1e12), spelled out either one digit at a time or two digits
|
|
at a time.
|
|
This rule is an INACTIVE toplevel rule, since it should go through GRID_INTEGER
|
|
to be formatted.
|
|
Explicitly disallow TWODIGIT DIGIT since that is ambiguous with "twenty five"
|
|
-->
|
|
<RULE NAME="GRID_DIGIT_NUMBER" ID="GRID_DIGIT_NUMBER" TOPLEVEL="INACTIVE" EXPORT="1">
|
|
<L>
|
|
<P MIN="3" MAX="12">
|
|
<L>
|
|
<P>
|
|
<RULEREF NAME="twodigit" PROPNAME="TWODIGIT" PROPID="TWODIGIT"/>
|
|
</P>
|
|
<P>
|
|
<RULEREF NAME="digit" PROPNAME="ONEDIGIT" PROPID="ONEDIGIT"/>
|
|
</P>
|
|
</L>
|
|
</P>
|
|
<P>
|
|
<P>
|
|
<RULEREF NAME="digit" PROPNAME="ONEDIGIT" PROPID="ONEDIGIT"/>
|
|
</P>
|
|
<P>
|
|
<RULEREF NAME="twodigit" PROPNAME="TWODIGIT" PROPID="TWODIGIT"/>
|
|
</P>
|
|
</P>
|
|
<P MIN="2" MAX="2">
|
|
|
|
<RULEREF NAME="twodigit" PROPNAME="TWODIGIT" PROPID="TWODIGIT"/>
|
|
</P>
|
|
<P MIN="2" MAX="2">
|
|
<RULEREF NAME="digit" PROPNAME="ONEDIGIT" PROPID="ONEDIGIT"/>
|
|
</P>
|
|
</L>
|
|
</RULE>
|
|
<!--
|
|
fp_number_nonneg
|
|
Floating-point numbers with up to 12 sig figs. Both the stuff to the left of the
|
|
decimal point and the stuff to the right of the decimal point can be either
|
|
NUMBERs or DIGIT_NUMBERs
|
|
-->
|
|
<RULE NAME="GRID_FP_NUMBER_NONNEG" ID="GRID_FP_NUMBER_NONNEG" TOPLEVEL="INACTIVE" EXPORT="1">
|
|
<RULEREF NAME="fp_number_nonneg"/>
|
|
</RULE>
|
|
|
|
<RULE NAME="fp_number_nonneg">
|
|
<O>
|
|
<L>
|
|
<P>
|
|
<RULEREF NAME="GRID_INTEGER_NONNEG" PROPNAME="ONES" PROPID="ONES"/>
|
|
</P>
|
|
<P PROPNAME="ZERO" PROPID="ZERO" VAL="0">
|
|
oh
|
|
</P>
|
|
</L>
|
|
</O>
|
|
<L>
|
|
<P>
|
|
point
|
|
</P>
|
|
<P>
|
|
decimal
|
|
</P>
|
|
</L>
|
|
<L>
|
|
<P>
|
|
<RULEREF NAME="GRID_DIGIT_BY_DIGIT" PROPNAME="FP_PART" PROPID="FP_PART"/>
|
|
</P>
|
|
<P>
|
|
<RULEREF NAME="GRID_INTEGER_999" PROPNAME="FP_PART" PROPID="FP_PART"/>
|
|
</P>
|
|
<P PROPNAME="POINT_ZERO" PROPID="POINT_ZERO" VAL="0">
|
|
oh
|
|
</P>
|
|
</L>
|
|
</RULE>
|
|
|
|
<!--
|
|
INTEGER_NONNEG
|
|
A INTEGER_NONNEG can be in the range [0, 1e12) and will never be called
|
|
as a toplevel rule
|
|
-->
|
|
<RULE NAME="GRID_INTEGER_NONNEG" ID="GRID_INTEGER_NONNEG" TOPLEVEL="INACTIVE" EXPORT="1">
|
|
<RULEREF NAME="integer_base_nonneg"/>
|
|
</RULE>
|
|
|
|
<!--
|
|
GRID_DIGIT_BY_DIGIT
|
|
GRID_DIGIT_BY_DIGIT will be used by fp_number_noneg as the floating part.
|
|
it will never be called as a toplevel rule
|
|
-->
|
|
<RULE NAME="GRID_DIGIT_BY_DIGIT" TOPLEVEL="INACTIVE" EXPORT="1">
|
|
<RULEREF NAME="GRID_DIGIT_NUMBER" PROPNAME="GRID_DIGIT_NUMBER" PROPID="GRID_DIGIT_NUMBER"/>
|
|
</RULE>
|
|
|
|
|
|
</GRAMMAR>
|