[Unicode]   Common Locale Data Repository : Bug Tracking Home | Site Map | Search
 

Changeset 9236


Ignore:
Timestamp:
08/20/13 03:22:45 (5 years ago)
Author:
markdavis
Message:

cldrbug 6544: fix to actually add the samples information to the files. Also made changes so that the new format was easier to compare with the old format.

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/common/dtd/ldmlSupplemental.dtd

    r9106 r9236  
    365365 
    366366<!ELEMENT pluralRule ( #PCDATA ) > 
    367 <!ATTLIST pluralRule count (zero | one | two | few | many) #REQUIRED > <!-- 'other' is implicitly everything else --> 
     367<!ATTLIST pluralRule count (zero | one | two | few | many | other) #REQUIRED > <!-- 'other' is implicitly everything else --> 
    368368<!ATTLIST pluralRule draft ( approved | contributed | provisional | unconfirmed ) #IMPLIED > 
    369369<!ATTLIST pluralRule references CDATA #IMPLIED > 
  • trunk/common/supplemental/ordinals.xml

    r9217 r9236  
    1010    <generation date="$Date$"/> 
    1111    <plurals type="ordinal"> 
    12         <pluralRules locales="af am ar bg cs da de el es et eu fa fi gl hr id in is he iw ja kn ko lt lv ml nb nl pl pt ru sk sl sr sh sw ta te th tr uk ur zh"/>  
    13         <pluralRules locales="fil tl fr ms ro mo vi"> 
    14             <pluralRule count="one">n is 1</pluralRule> 
     12        <!-- For a canonicalized list, use GeneratedPluralSamples --> 
     13        <!-- if locale is known to have no plurals, there are no rules --> 
     14        <pluralRules locales="af am ar bg cs da de el es et eu fa fi gl he hr id in is iw ja kn ko lt lv ml nb nl pl pt ru sh sk sl sr sw ta te th tr uk ur zh"> 
     15            <pluralRule count="other"> @integer 0~7, 10, 100, 1000, 10000, 100000, …</pluralRule> 
     16        </pluralRules> 
     17        <pluralRules locales="fil fr mo ms ro tl vi"> 
     18            <pluralRule count="one">n is 1 @integer 1</pluralRule> 
     19            <pluralRule count="other"> @integer 0, 2~8, 10, 100, 1000, 10000, 100000, …</pluralRule> 
    1520        </pluralRules> 
    1621        <pluralRules locales="hu"> 
    17             <pluralRule count="one">n in 1,5</pluralRule> 
     22            <pluralRule count="one">n in 1,5 @integer 1, 5</pluralRule> 
     23            <pluralRule count="other"> @integer 0, 2~4, 6~10, 100, 1000, 10000, 100000, …</pluralRule> 
    1824        </pluralRules> 
    1925        <pluralRules locales="sv"> 
    20             <pluralRule count="one">n mod 10 in 1,2 and n mod 100 not in 11,12</pluralRule> 
     26            <pluralRule count="one">n mod 10 in 1,2 and n mod 100 not in 11,12 @integer 1, 2, 21, 22, 31, 32, 41, 42, 101, 1001</pluralRule> 
     27            <pluralRule count="other"> @integer 0, 3~10, 100, 1000, 10000, 100000, …</pluralRule> 
    2128        </pluralRules> 
    2229        <pluralRules locales="en"> 
    23             <pluralRule count="one">n mod 10 is 1 and n mod 100 is not 11</pluralRule> 
    24             <pluralRule count="two">n mod 10 is 2 and n mod 100 is not 12</pluralRule> 
    25             <pluralRule count="few">n mod 10 is 3 and n mod 100 is not 13</pluralRule> 
     30            <pluralRule count="one">n mod 10 is 1 and n mod 100 is not 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001</pluralRule> 
     31            <pluralRule count="two">n mod 10 is 2 and n mod 100 is not 12 @integer 2, 22, 32, 42, 52, 62, 72, 82, 102, 1002</pluralRule> 
     32            <pluralRule count="few">n mod 10 is 3 and n mod 100 is not 13 @integer 3, 23, 33, 43, 53, 63, 73, 83, 103, 1003</pluralRule> 
     33            <pluralRule count="other"> @integer 0, 4~10, 100, 1000, 10000, 100000, …</pluralRule> 
    2634        </pluralRules> 
    2735        <pluralRules locales="it"> 
    28             <!-- n is 11 or n is 8 * 10^x, where x >= 0 --> 
    29             <pluralRule count="many">n in 11,8,80,800</pluralRule> 
     36            <pluralRule count="many">n in 11,8,80,800 @integer 8, 11, 80, 800</pluralRule> 
     37            <pluralRule count="other"> @integer 0~7, 10, 100, 1000, 10000, 100000, …</pluralRule> 
    3038        </pluralRules> 
    3139        <pluralRules locales="ca"> 
    32             <pluralRule count="one">n in 1,3</pluralRule> 
    33             <pluralRule count="two">n is 2</pluralRule> 
    34             <pluralRule count="few">n is 4</pluralRule> 
     40            <pluralRule count="one">n in 1,3 @integer 1, 3</pluralRule> 
     41            <pluralRule count="two">n is 2 @integer 2</pluralRule> 
     42            <pluralRule count="few">n is 4 @integer 4</pluralRule> 
     43            <pluralRule count="other"> @integer 0, 5~11, 100, 1000, 10000, 100000, …</pluralRule> 
    3544        </pluralRules> 
    3645        <pluralRules locales="mr"> 
    37             <pluralRule count="one">n is 1</pluralRule> 
    38             <pluralRule count="two">n in 2,3</pluralRule> 
    39             <pluralRule count="few">n is 4</pluralRule> 
     46            <pluralRule count="one">n is 1 @integer 1</pluralRule> 
     47            <pluralRule count="two">n in 2,3 @integer 2, 3</pluralRule> 
     48            <pluralRule count="few">n is 4 @integer 4</pluralRule> 
     49            <pluralRule count="other"> @integer 0, 5~11, 100, 1000, 10000, 100000, …</pluralRule> 
    4050        </pluralRules> 
    4151        <pluralRules locales="gu hi"> 
    42             <pluralRule count="one">n is 1</pluralRule> 
    43             <pluralRule count="two">n in 2,3</pluralRule> 
    44             <pluralRule count="few">n is 4</pluralRule> 
    45             <pluralRule count="many">n is 6</pluralRule> 
     52            <pluralRule count="one">n is 1 @integer 1</pluralRule> 
     53            <pluralRule count="two">n in 2,3 @integer 2, 3</pluralRule> 
     54            <pluralRule count="few">n is 4 @integer 4</pluralRule> 
     55            <pluralRule count="many">n is 6 @integer 6</pluralRule> 
     56            <pluralRule count="other"> @integer 0, 5, 7~12, 100, 1000, 10000, 100000, …</pluralRule> 
    4657        </pluralRules> 
    4758        <pluralRules locales="bn"> 
    48             <pluralRule count="one">n in 1,5,7,8,9,10</pluralRule> 
    49             <pluralRule count="two">n in 2,3</pluralRule> 
    50             <pluralRule count="few">n is 4</pluralRule> 
    51             <pluralRule count="many">n is 6</pluralRule> 
     59            <pluralRule count="one">n in 1,5,7,8,9,10 @integer 1, 5, 7~10</pluralRule> 
     60            <pluralRule count="two">n in 2,3 @integer 2, 3</pluralRule> 
     61            <pluralRule count="few">n is 4 @integer 4</pluralRule> 
     62            <pluralRule count="many">n is 6 @integer 6</pluralRule> 
     63            <pluralRule count="other"> @integer 0, 11~17, 100, 1000, 10000, 100000, …</pluralRule> 
    5264        </pluralRules> 
    53             <pluralRules locales="zu"> 
    54                 <pluralRule count="one">n is 1</pluralRule> 
    55                 <pluralRule count="few">n in 2..9</pluralRule> 
    56                 <!-- n starts with a 1 and n > 1 --> 
    57                 <pluralRule count="many">n in 10..19,100..199,1000..1999</pluralRule> 
    58             </pluralRules> 
     65        <pluralRules locales="zu"> 
     66            <pluralRule count="one">n is 1 @integer 1</pluralRule> 
     67            <pluralRule count="few">n in 2..9 @integer 2~9</pluralRule> 
     68            <pluralRule count="many">n in 10..19,100..199,1000..1999 @integer 10~17, 100, 1000</pluralRule> 
     69            <pluralRule count="other"> @integer 0, 20~26, 200, 2000, 10000, 100000, …</pluralRule> 
     70        </pluralRules> 
    5971    </plurals> 
    6072</supplementalData> 
  • trunk/common/supplemental/plurals.xml

    r9232 r9236  
    99    <version number="$Revision$"/> 
    1010    <generation date="$Date$"/> 
    11     <plurals> 
    12         <!-- For a canonicalized list, use WritePluralRules --> 
     11    <plurals type="cardinal"> 
     12        <!-- For a canonicalized list, use GeneratedPluralSamples --> 
    1313        <!-- if locale is known to have no plurals, there are no rules --> 
    1414        <pluralRules locales="ar"> 
    15             <pluralRule count="zero">n is 0</pluralRule> 
    16             <pluralRule count="one">n is 1</pluralRule> 
    17             <pluralRule count="two">n is 2</pluralRule> 
    18             <pluralRule count="few">n mod 100 in 3..10</pluralRule> 
    19             <pluralRule count="many">n mod 100 in 11..99</pluralRule> 
     15            <pluralRule count="zero">n is 0 @integer 0 @decimal 0.0, 0.00, 0.000, 0.0000</pluralRule> 
     16            <pluralRule count="one">n is 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000</pluralRule> 
     17            <pluralRule count="two">n is 2 @integer 2 @decimal 2.0, 2.00, 2.000, 2.0000</pluralRule> 
     18            <pluralRule count="few">n mod 100 in 3..10 @integer 3~10, 103, 1003 @decimal 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 103.0, 1003.0, …</pluralRule> 
     19            <pluralRule count="many">n mod 100 in 11..99 @integer 11~18, 111, 1011 @decimal 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 111.0, 1011.0, …</pluralRule> 
     20            <pluralRule count="other"> @integer 100~102, 200~202, 300, 301, 1000, 10000, 100000, … @decimal 0.1~0.8, 10.1, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    2021        </pluralRules> 
    2122        <pluralRules locales="he iw"> 
    22             <pluralRule count="one">i is 1 and v is 0</pluralRule> 
    23             <pluralRule count="two">i is 2 and v is 0</pluralRule> 
    24             <pluralRule count="many">v is 0 and i not in 0..10 and i mod 10 is 0</pluralRule> 
     23            <pluralRule count="one">i is 1 and v is 0 @integer 1</pluralRule> 
     24            <pluralRule count="two">i is 2 and v is 0 @integer 2</pluralRule> 
     25            <pluralRule count="many">v is 0 and i not in 0..10 and i mod 10 is 0 @integer 20, 30, 40, 50, 60, 70, 80, 90, 100, 1000, 10000, 100000</pluralRule> 
     26            <pluralRule count="other"> @integer 0, 3~10, 101, 1001, … @decimal 0.0~0.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    2527        </pluralRules> 
    2628        <pluralRules locales="af asa ast az bem bez bg brx cgg chr ckb dv ee el eo es eu fo fur fy gsw ha haw hu jgo jmc ka kaj kcg kk kkj kl ks ksb ku ky lb lg mas mgo ml mn nah nb nd ne nn nnh no nr ny nyn om or os pap ps rm rof rwk saq seh sn so sq ss ssy st syr ta te teo tig tk tn tr ts uz ve vo vun wae xh xog"> 
    27             <pluralRule count="one">n is 1</pluralRule> 
     29            <pluralRule count="one">n is 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000</pluralRule> 
     30            <pluralRule count="other"> @integer 0, 2~8, 10, 100, 1000, 10000, 100000, … @decimal 0.0~0.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    2831        </pluralRules> 
    2932        <pluralRules locales="ak bh guw ln mg nso pa ti wa"> 
    30             <pluralRule count="one">n in 0..1</pluralRule> 
     33            <pluralRule count="one">n in 0..1 @integer 0, 1 @decimal 0.0, 1.0, 0.00, 1.00, 0.000, 1.000, 0.0000, 1.0000</pluralRule> 
     34            <pluralRule count="other"> @integer 2~10, 100, 1000, 10000, 100000, … @decimal 0.1~0.8, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    3135        </pluralRules> 
    3236        <pluralRules locales="ff fr hy kab"> 
    33             <pluralRule count="one">i is 0,1</pluralRule> 
     37            <pluralRule count="one">i is 0,1 @integer 0, 1 @decimal 0.0~0.7</pluralRule> 
     38            <pluralRule count="other"> @integer 2~10, 100, 1000, 10000, 100000, … @decimal 2.0~2.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    3439        </pluralRules> 
    3540        <pluralRules locales="lv"> 
    36             <pluralRule count="zero">n mod 10 is 0 or n mod 100 in 11..19 or v is 2 and f mod 100 in 11..19</pluralRule> 
    37             <pluralRule count="one">n mod 10 is 1 and n mod 100 is not 11 or v is 2 and f mod 10 is 1 and f mod 100 is not 11 or v is not 2 and f mod 10 is 1</pluralRule> 
     41            <pluralRule count="zero">n mod 10 is 0 or n mod 100 in 11..19 or v is 2 and f mod 100 in 11..19 @integer 0, 10~16, 100, 1000, 10000, 100000 @decimal 0.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
     42            <pluralRule count="one">n mod 10 is 1 and n mod 100 is not 11 or v is 2 and f mod 10 is 1 and f mod 100 is not 11 or v is not 2 and f mod 10 is 1 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001 @decimal 0.1, 1.0, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 10.1, 100.1, 1000.1, …</pluralRule> 
     43            <pluralRule count="other"> @integer 2~9, 22, 102, 1002, … @decimal 0.2~0.9, 10.2, 100.2, 1000.2, …</pluralRule> 
    3844        </pluralRules> 
    3945        <pluralRules locales="iu kw naq se sma smi smj smn sms"> 
    40             <pluralRule count="one">n is 1</pluralRule> 
    41             <pluralRule count="two">n is 2</pluralRule> 
     46            <pluralRule count="one">n is 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000</pluralRule> 
     47            <pluralRule count="two">n is 2 @integer 2 @decimal 2.0, 2.00, 2.000, 2.0000</pluralRule> 
     48            <pluralRule count="other"> @integer 0, 3~10, 100, 1000, 10000, 100000, … @decimal 0.0~0.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    4249        </pluralRules> 
    4350        <pluralRules locales="ga"> 
    44             <pluralRule count="one">n is 1</pluralRule> 
    45             <pluralRule count="two">n is 2</pluralRule> 
    46             <pluralRule count="few">n in 3..6</pluralRule> 
    47             <pluralRule count="many">n in 7..10</pluralRule> 
     51            <pluralRule count="one">n is 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000</pluralRule> 
     52            <pluralRule count="two">n is 2 @integer 2 @decimal 2.0, 2.00, 2.000, 2.0000</pluralRule> 
     53            <pluralRule count="few">n in 3..6 @integer 3~6 @decimal 3.0, 4.0, 5.0, 6.0, 3.00, 4.00, 5.00, 6.00</pluralRule> 
     54            <pluralRule count="many">n in 7..10 @integer 7~10 @decimal 7.0, 8.0, 9.0, 10.0, 7.00, 8.00, 9.00, 10.00</pluralRule> 
     55            <pluralRule count="other"> @integer 0, 11~17, 100, 1000, 10000, 100000, … @decimal 0.0~0.7, 10.1, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    4856        </pluralRules> 
    4957        <pluralRules locales="mo ro"> 
    50             <pluralRule count="one">i is 1 and v is 0</pluralRule> 
    51             <pluralRule count="few">v is not 0 or n is 0 or n is not 1 and n mod 100 in 1..19</pluralRule> 
     58            <pluralRule count="one">i is 1 and v is 0 @integer 1</pluralRule> 
     59            <pluralRule count="few">v is not 0 or n is 0 or n is not 1 and n mod 100 in 1..19 @integer 0, 2~8, 10, 101, 1001 @decimal 0.0~0.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
     60            <pluralRule count="other"> @integer 20~27, 100, 1000, 10000, 100000, …</pluralRule> 
    5261        </pluralRules> 
    5362        <pluralRules locales="lt"> 
    54             <pluralRule count="one">n mod 10 is 1 and n mod 100 not in 11..19</pluralRule> 
    55             <pluralRule count="few">n mod 10 in 2..9 and n mod 100 not in 11..19</pluralRule> 
    56             <pluralRule count="many">f is not 0</pluralRule> 
     63            <pluralRule count="one">n mod 10 is 1 and n mod 100 not in 11..19 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001 @decimal 1.0, 21.0, 31.0, 41.0, 51.0, 61.0, 71.0, 81.0, 101.0, 1001.0, …</pluralRule> 
     64            <pluralRule count="few">n mod 10 in 2..9 and n mod 100 not in 11..19 @integer 2~9, 22, 102, 1002 @decimal 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 22.0, 102.0, 1002.0, …</pluralRule> 
     65            <pluralRule count="many">f is not 0   @decimal 0.1~0.8, 10.1, 100.1, 1000.1</pluralRule> 
     66            <pluralRule count="other"> @integer 0, 10~16, 100, 1000, 10000, 100000, … @decimal 0.0, 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    5767        </pluralRules> 
    5868        <pluralRules locales="be"> 
    59             <pluralRule count="one">n mod 10 is 1 and n mod 100 is not 11</pluralRule> 
    60             <pluralRule count="few">n mod 10 in 2..4 and n mod 100 not in 12..14</pluralRule> 
    61             <pluralRule count="many">n mod 10 is 0 or n mod 10 in 5..9 or n mod 100 in 11..14</pluralRule> 
     69            <pluralRule count="one">n mod 10 is 1 and n mod 100 is not 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001 @decimal 1.0, 21.0, 31.0, 41.0, 51.0, 61.0, 71.0, 81.0, 101.0, 1001.0, …</pluralRule> 
     70            <pluralRule count="few">n mod 10 in 2..4 and n mod 100 not in 12..14 @integer 2~4, 22~24, 32, 33, 102, 1002 @decimal 2.0, 3.0, 4.0, 22.0, 23.0, 24.0, 32.0, 33.0, 102.0, 1002.0, …</pluralRule> 
     71            <pluralRule count="many">n mod 10 is 0 or n mod 10 in 5..9 or n mod 100 in 11..14 @integer 0, 5~11, 100, 1000, 10000, 100000 @decimal 0.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
     72            <pluralRule count="other">   @decimal 0.1~0.8, 10.1, 100.1, 1000.1, …</pluralRule> 
    6273        </pluralRules> 
    6374        <pluralRules locales="cs sk"> 
    64             <pluralRule count="one">i is 1 and v is 0</pluralRule> 
    65             <pluralRule count="few">i in 2..4 and v is 0</pluralRule> 
    66             <pluralRule count="many">v is not 0</pluralRule> 
     75            <pluralRule count="one">i is 1 and v is 0 @integer 1</pluralRule> 
     76            <pluralRule count="few">i in 2..4 and v is 0 @integer 2~4</pluralRule> 
     77            <pluralRule count="many">v is not 0   @decimal 0.0~0.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
     78            <pluralRule count="other"> @integer 0, 5~11, 100, 1000, 10000, 100000, …</pluralRule> 
    6779        </pluralRules> 
    6880        <pluralRules locales="pl"> 
    69             <pluralRule count="one">i is 1 and v is 0</pluralRule> 
    70             <pluralRule count="few">v is 0 and i mod 10 in 2..4 and i mod 100 not in 12..14</pluralRule> 
    71             <pluralRule count="many">v is 0 and i is not 1 and i mod 10 in 0..1 or v is 0 and i mod 10 in 5..9 or v is 0 and i mod 100 in 12..14</pluralRule> 
     81            <pluralRule count="one">i is 1 and v is 0 @integer 1</pluralRule> 
     82            <pluralRule count="few">v is 0 and i mod 10 in 2..4 and i mod 100 not in 12..14 @integer 2~4, 22~24, 32, 33, 102, 1002</pluralRule> 
     83            <pluralRule count="many">v is 0 and i is not 1 and i mod 10 in 0..1 or v is 0 and i mod 10 in 5..9 or v is 0 and i mod 100 in 12..14 @integer 0, 5~11, 100, 1000, 10000, 100000</pluralRule> 
     84            <pluralRule count="other">   @decimal 0.0~0.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    7285        </pluralRules> 
    7386        <pluralRules locales="sl"> 
    74             <pluralRule count="one">v is 0 and i mod 100 is 1</pluralRule> 
    75             <pluralRule count="two">v is 0 and i mod 100 is 2</pluralRule> 
    76             <pluralRule count="few">v is 0 and i mod 100 in 3..4 or v is not 0</pluralRule> 
     87            <pluralRule count="one">v is 0 and i mod 100 is 1 @integer 1, 101, 201, 301, 401, 501, 601, 701, 1001</pluralRule> 
     88            <pluralRule count="two">v is 0 and i mod 100 is 2 @integer 2, 102, 202, 302, 402, 502, 602, 702, 1002</pluralRule> 
     89            <pluralRule count="few">v is 0 and i mod 100 in 3..4 or v is not 0 @integer 3, 4, 103, 104, 203, 204, 303, 304, 1003 @decimal 0.0~0.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
     90            <pluralRule count="other"> @integer 0, 5~11, 100, 1000, 10000, 100000, …</pluralRule> 
    7791        </pluralRules> 
    7892        <pluralRules locales="mt"> 
    79             <pluralRule count="one">n is 1</pluralRule> 
    80             <pluralRule count="few">n is 0 or n mod 100 in 2..10</pluralRule> 
    81             <pluralRule count="many">n mod 100 in 11..19</pluralRule> 
     93            <pluralRule count="one">n is 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000</pluralRule> 
     94            <pluralRule count="few">n is 0 or n mod 100 in 2..10 @integer 0, 2~8, 10, 102, 1002 @decimal 0.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0, 102.0, 1002.0, …</pluralRule> 
     95            <pluralRule count="many">n mod 100 in 11..19 @integer 11~18, 111, 1011 @decimal 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0, 18.0, 111.0, 1011.0, …</pluralRule> 
     96            <pluralRule count="other"> @integer 20~27, 100, 1000, 10000, 100000, … @decimal 0.1~0.8, 10.1, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    8297        </pluralRules> 
    8398        <pluralRules locales="mk"> 
    84             <pluralRule count="one">v is 0 and i mod 10 is 1 or f mod 10 is 1</pluralRule> 
     99            <pluralRule count="one">v is 0 and i mod 10 is 1 or f mod 10 is 1 @integer 1, 11, 21, 31, 41, 51, 61, 71, 101, 1001 @decimal 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 10.1, 100.1, 1000.1, …</pluralRule> 
     100            <pluralRule count="other"> @integer 0, 2~8, 10, 100, 1000, 10000, 100000, … @decimal 0.0, 0.2~0.8, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    85101        </pluralRules> 
    86102        <pluralRules locales="cy"> 
    87             <pluralRule count="zero">n is 0</pluralRule> 
    88             <pluralRule count="one">n is 1</pluralRule> 
    89             <pluralRule count="two">n is 2</pluralRule> 
    90             <pluralRule count="few">n is 3</pluralRule> 
    91             <pluralRule count="many">n is 6</pluralRule> 
     103            <pluralRule count="zero">n is 0 @integer 0 @decimal 0.0, 0.00, 0.000, 0.0000</pluralRule> 
     104            <pluralRule count="one">n is 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000</pluralRule> 
     105            <pluralRule count="two">n is 2 @integer 2 @decimal 2.0, 2.00, 2.000, 2.0000</pluralRule> 
     106            <pluralRule count="few">n is 3 @integer 3 @decimal 3.0, 3.00, 3.000, 3.0000</pluralRule> 
     107            <pluralRule count="many">n is 6 @integer 6 @decimal 6.0, 6.00, 6.000, 6.0000</pluralRule> 
     108            <pluralRule count="other"> @integer 4, 5, 7~12, 100, 1000, 10000, 100000, … @decimal 0.1~0.8, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    92109        </pluralRules> 
    93110        <pluralRules locales="lag"> 
    94             <pluralRule count="zero">n is 0</pluralRule> 
    95             <pluralRule count="one">i is 0,1 and n is not 0</pluralRule> 
     111            <pluralRule count="zero">n is 0 @integer 0 @decimal 0.0, 0.00, 0.000, 0.0000</pluralRule> 
     112            <pluralRule count="one">i is 0,1 and n is not 0 @integer 1 @decimal 0.1~0.8</pluralRule> 
     113            <pluralRule count="other"> @integer 2~10, 100, 1000, 10000, 100000, … @decimal 2.0~2.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    96114        </pluralRules> 
    97115        <pluralRules locales="shi"> 
    98             <pluralRule count="one">i is 0 or n is 1</pluralRule> 
    99             <pluralRule count="few">n in 2..10</pluralRule> 
     116            <pluralRule count="one">i is 0 or n is 1 @integer 0, 1 @decimal 0.0~0.7</pluralRule> 
     117            <pluralRule count="few">n in 2..10 @integer 2~10 @decimal 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0</pluralRule> 
     118            <pluralRule count="other"> @integer 11~18, 100, 1000, 10000, 100000, … @decimal 1.1~1.8, 10.1, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    100119        </pluralRules> 
    101120        <pluralRules locales="br"> 
    102             <pluralRule count="one">n mod 10 is 1 and n mod 100 not in 11,71,91</pluralRule> 
    103             <pluralRule count="two">n mod 10 is 2 and n mod 100 not in 12,72,92</pluralRule> 
    104             <pluralRule count="few">n mod 10 in 3..4,9 and n mod 100 not in 10..19,70..79,90..99</pluralRule> 
    105             <pluralRule count="many">n is not 0 and n mod 1000000 is 0</pluralRule> 
     121            <pluralRule count="one">n mod 10 is 1 and n mod 100 not in 11,71,91 @integer 1, 21, 31, 41, 51, 61, 81, 101, 1001 @decimal 1.0, 21.0, 31.0, 41.0, 51.0, 61.0, 81.0, 101.0, 1001.0, …</pluralRule> 
     122            <pluralRule count="two">n mod 10 is 2 and n mod 100 not in 12,72,92 @integer 2, 22, 32, 42, 52, 62, 82, 102, 1002 @decimal 2.0, 22.0, 32.0, 42.0, 52.0, 62.0, 82.0, 102.0, 1002.0, …</pluralRule> 
     123            <pluralRule count="few">n mod 10 in 3..4,9 and n mod 100 not in 10..19,70..79,90..99 @integer 3, 4, 9, 23, 24, 29, 33, 34, 103, 1003 @decimal 3.0, 4.0, 9.0, 23.0, 24.0, 29.0, 33.0, 34.0, 103.0, 1003.0, …</pluralRule> 
     124            <pluralRule count="many">n is not 0 and n mod 1000000 is 0   @decimal 1000000.0, 1000000.00, 1000000.000</pluralRule> 
     125            <pluralRule count="other"> @integer 0, 5~8, 10~12, 100, 1000, 10000, 100000, … @decimal 0.0~0.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, …</pluralRule> 
    106126        </pluralRules> 
    107127        <pluralRules locales="ksh"> 
    108             <pluralRule count="zero">n is 0</pluralRule> 
    109             <pluralRule count="one">n is 1</pluralRule> 
     128            <pluralRule count="zero">n is 0 @integer 0 @decimal 0.0, 0.00, 0.000, 0.0000</pluralRule> 
     129            <pluralRule count="one">n is 1 @integer 1 @decimal 1.0, 1.00, 1.000, 1.0000</pluralRule> 
     130            <pluralRule count="other"> @integer 2~10, 100, 1000, 10000, 100000, … @decimal 0.1~0.8, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    110131        </pluralRules> 
    111132        <pluralRules locales="tzm"> 
    112             <pluralRule count="one">n in 0..1 or n in 11..99</pluralRule> 
     133            <pluralRule count="one">n in 0..1 or n in 11..99 @integer 0, 1, 11~16 @decimal 0.0, 1.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0</pluralRule> 
     134            <pluralRule count="other"> @integer 2~10, 100, 1000, 10000, 100000, … @decimal 0.1~0.8, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    113135        </pluralRules> 
    114136        <pluralRules locales="gv"> 
    115             <pluralRule count="one">n mod 10 is 1</pluralRule> 
    116             <pluralRule count="two">n mod 10 is 2</pluralRule> 
    117             <pluralRule count="few">n mod 100 in 0,20,40,60</pluralRule> 
     137            <pluralRule count="one">n mod 10 is 1 @integer 1, 11, 21, 31, 41, 51, 61, 71, 101, 1001 @decimal 1.0, 11.0, 21.0, 31.0, 41.0, 51.0, 61.0, 71.0, 101.0, 1001.0, …</pluralRule> 
     138            <pluralRule count="two">n mod 10 is 2 @integer 2, 12, 22, 32, 42, 52, 62, 72, 102, 1002 @decimal 2.0, 12.0, 22.0, 32.0, 42.0, 52.0, 62.0, 72.0, 102.0, 1002.0, …</pluralRule> 
     139            <pluralRule count="few">n mod 100 in 0,20,40,60 @integer 0, 20, 40, 60, 100, 120, 140, 160, 1000, 10000, 100000 @decimal 0.0, 20.0, 40.0, 60.0, 100.0, 120.0, 140.0, 160.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
     140            <pluralRule count="other"> @integer 3~10, 103, 1003, … @decimal 0.1~0.8, 10.0, 100.1, 1000.1, …</pluralRule> 
    118141        </pluralRules> 
    119142        <pluralRules locales="gd"> 
    120             <pluralRule count="one">n in 1,11</pluralRule> 
    121             <pluralRule count="two">n in 2,12</pluralRule> 
    122             <pluralRule count="few">n in 3..10,13..19</pluralRule> 
    123         </pluralRules> 
    124         <pluralRules locales="bm bo dz id in ig ii ja jbo jv jw kde kea km ko lkt lo ms my nqo sah ses sg th to vi wo yo zh"> 
     143            <pluralRule count="one">n in 1,11 @integer 1, 11 @decimal 1.0, 11.0, 1.00, 11.00, 1.000, 11.000, 1.0000</pluralRule> 
     144            <pluralRule count="two">n in 2,12 @integer 2, 12 @decimal 2.0, 12.0, 2.00, 12.00, 2.000, 12.000, 2.0000</pluralRule> 
     145            <pluralRule count="few">n in 3..10,13..19 @integer 3~10 @decimal 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0</pluralRule> 
     146            <pluralRule count="other"> @integer 0, 20~26, 100, 1000, 10000, 100000, … @decimal 0.0~0.7, 10.1, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
     147        </pluralRules> 
     148        <pluralRules locales="bm bo dz id ig ii in ja jbo jv jw kde kea km ko lkt lo ms my nqo sah ses sg th to vi wo yo zh"> 
     149            <pluralRule count="other"> @integer 0~7, 10, 100, 1000, 10000, 100000, … @decimal 0.0~0.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    125150        </pluralRules> 
    126151        <pluralRules locales="fil tl"> 
    127             <pluralRule count="one">i in 0..1 and v is 0</pluralRule> 
    128         </pluralRules> 
    129         <pluralRules locales="ca de en et fi gl it nl sv sw ur yi ji"> 
    130             <pluralRule count="one">i is 1 and v is 0</pluralRule> 
     152            <pluralRule count="one">i in 0..1 and v is 0 @integer 0, 1</pluralRule> 
     153            <pluralRule count="other"> @integer 2~10, 100, 1000, 10000, 100000, … @decimal 0.0~0.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
     154        </pluralRules> 
     155        <pluralRules locales="ca de en et fi gl it ji nl sv sw ur yi"> 
     156            <pluralRule count="one">i is 1 and v is 0 @integer 1</pluralRule> 
     157            <pluralRule count="other"> @integer 0, 2~8, 10, 100, 1000, 10000, 100000, … @decimal 0.0~0.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    131158        </pluralRules> 
    132159        <pluralRules locales="pt"> 
    133             <pluralRule count="one">i is 1 and v is 0 or f is 1</pluralRule> 
     160            <pluralRule count="one">i is 1 and v is 0 or f is 1 @integer 1 @decimal 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 10.1, 100.1, 1000.1</pluralRule> 
     161            <pluralRule count="other"> @integer 0, 2~8, 10, 100, 1000, 10000, 100000, … @decimal 0.0, 0.2~0.8, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    134162        </pluralRules> 
    135163        <pluralRules locales="da"> 
    136             <pluralRule count="one">n is 1 or t is not 0 and i is 0,1</pluralRule> 
     164            <pluralRule count="one">n is 1 or t is not 0 and i is 0,1 @integer 1 @decimal 0.1~0.8</pluralRule> 
     165            <pluralRule count="other"> @integer 0, 2~8, 10, 100, 1000, 10000, 100000, … @decimal 0.0, 2.0~2.6, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    137166        </pluralRules> 
    138167        <pluralRules locales="pt_PT"> 
    139             <pluralRule count="one">n is 1 or t is 1</pluralRule> 
     168            <pluralRule count="one">n is 1 or t is 1 @integer 1 @decimal 0.1, 1.0, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 10.1, 100.1, 1000.1</pluralRule> 
     169            <pluralRule count="other"> @integer 0, 2~8, 10, 100, 1000, 10000, 100000, … @decimal 0.0, 0.2~0.8, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    140170        </pluralRules> 
    141171        <pluralRules locales="am bn fa gu hi kn mr zu"> 
    142             <pluralRule count="one">i is 0 or n is 1</pluralRule> 
     172            <pluralRule count="one">i is 0 or n is 1 @integer 0, 1 @decimal 0.0~0.7</pluralRule> 
     173            <pluralRule count="other"> @integer 2~10, 100, 1000, 10000, 100000, … @decimal 1.1~1.8, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    143174        </pluralRules> 
    144175        <pluralRules locales="is"> 
    145             <pluralRule count="one">t is 0 and i mod 10 is 1 and i mod 100 is not 11 or t is not 0</pluralRule> 
     176            <pluralRule count="one">t is 0 and i mod 10 is 1 and i mod 100 is not 11 or t is not 0 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001 @decimal 0.1~0.8, 10.1, 100.1, 1000.1</pluralRule> 
     177            <pluralRule count="other"> @integer 0, 2~8, 10, 100, 1000, 10000, 100000, … @decimal 0.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    146178        </pluralRules> 
    147179        <pluralRules locales="si"> 
    148             <pluralRule count="one">n in 0,1 or i is 0 and f is 1</pluralRule> 
     180            <pluralRule count="one">n in 0,1 or i is 0 and f is 1 @integer 0, 1 @decimal 0.0, 0.1, 1.0, 0.00, 0.01, 1.00, 0.000, 0.001</pluralRule> 
     181            <pluralRule count="other"> @integer 2~10, 100, 1000, 10000, 100000, … @decimal 0.2~0.9, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    149182        </pluralRules> 
    150183        <pluralRules locales="bs hr sh sr"> 
    151             <pluralRule count="one">v is 0 and i mod 10 is 1 and i mod 100 is not 11 or f mod 10 is 1 and f mod 100 is not 11</pluralRule> 
    152             <pluralRule count="few">v is 0 and i mod 10 in 2..4 and i mod 100 not in 12..14 or f mod 10 in 2..4 and f mod 100 not in 12..14</pluralRule> 
     184            <pluralRule count="one">v is 0 and i mod 10 is 1 and i mod 100 is not 11 or f mod 10 is 1 and f mod 100 is not 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001 @decimal 0.1, 1.1, 2.1, 3.1, 4.1, 5.1, 6.1, 7.1, 10.1, 100.1, 1000.1, …</pluralRule> 
     185            <pluralRule count="few">v is 0 and i mod 10 in 2..4 and i mod 100 not in 12..14 or f mod 10 in 2..4 and f mod 100 not in 12..14 @integer 2~4, 22~24, 32, 33, 102, 1002 @decimal 0.2~0.4, 1.2~1.4, 2.2, 2.3, 10.2, 100.2, 1000.2, …</pluralRule> 
     186            <pluralRule count="other"> @integer 0, 5~11, 100, 1000, 10000, 100000, … @decimal 0.0, 0.5~1.0, 1.5, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    153187        </pluralRules> 
    154188        <pluralRules locales="ru"> 
    155             <pluralRule count="one">v is 0 and i mod 10 is 1 and i mod 100 is not 11</pluralRule> 
    156             <pluralRule count="many">v is 0 and i mod 10 is 0 or v is 0 and i mod 10 in 5..9 or v is 0 and i mod 100 in 11..14</pluralRule> 
     189            <pluralRule count="one">v is 0 and i mod 10 is 1 and i mod 100 is not 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001</pluralRule> 
     190            <pluralRule count="many">v is 0 and i mod 10 is 0 or v is 0 and i mod 10 in 5..9 or v is 0 and i mod 100 in 11..14 @integer 0, 5~11, 100, 1000, 10000, 100000</pluralRule> 
     191            <pluralRule count="other"> @integer 2~4, 22~24, 32, 33, 102, 1002, … @decimal 0.0~0.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    157192        </pluralRules> 
    158193        <pluralRules locales="uk"> 
    159             <pluralRule count="one">v is 0 and i mod 10 is 1 and i mod 100 is not 11</pluralRule> 
    160             <pluralRule count="few">v is 0 and i mod 10 in 2..4 and i mod 100 not in 12..14</pluralRule> 
    161             <pluralRule count="many">v is 0 and i mod 10 is 0 or v is 0 and i mod 10 in 5..9 or v is 0 and i mod 100 in 11..14</pluralRule> 
     194            <pluralRule count="one">v is 0 and i mod 10 is 1 and i mod 100 is not 11 @integer 1, 21, 31, 41, 51, 61, 71, 81, 101, 1001</pluralRule> 
     195            <pluralRule count="few">v is 0 and i mod 10 in 2..4 and i mod 100 not in 12..14 @integer 2~4, 22~24, 32, 33, 102, 1002</pluralRule> 
     196            <pluralRule count="many">v is 0 and i mod 10 is 0 or v is 0 and i mod 10 in 5..9 or v is 0 and i mod 100 in 11..14 @integer 0, 5~11, 100, 1000, 10000, 100000</pluralRule> 
     197            <pluralRule count="other">   @decimal 0.0~0.7, 10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, …</pluralRule> 
    162198        </pluralRules> 
    163199    </plurals> 
  • trunk/tools/java/org/unicode/cldr/tool/GeneratedPluralSamples.java

    r9232 r9236  
    11package org.unicode.cldr.tool; 
    22 
     3import java.io.BufferedReader; 
     4import java.io.PrintWriter; 
    35import java.util.Arrays; 
     6import java.util.Comparator; 
    47import java.util.HashMap; 
    58import java.util.HashSet; 
     
    1518import java.util.regex.Pattern; 
    1619 
     20import org.unicode.cldr.draft.FileUtilities; 
     21import org.unicode.cldr.tool.GeneratedPluralSamples.Info.Type; 
    1722import org.unicode.cldr.tool.GeneratedPluralSamples.Range.Status; 
    1823import org.unicode.cldr.tool.Option.Options; 
     24import org.unicode.cldr.tool.WritePluralRules.PluralRulesComparator; 
    1925import org.unicode.cldr.unittest.TestAll.TestInfo; 
    2026import org.unicode.cldr.util.CldrUtility; 
     
    2430import org.unicode.cldr.util.SupplementalDataInfo.PluralType; 
    2531 
     32import com.ibm.icu.dev.util.BagFormatter; 
    2633import com.ibm.icu.dev.util.CollectionUtilities; 
    2734import com.ibm.icu.dev.util.Relation; 
     35import com.ibm.icu.impl.Row; 
    2836import com.ibm.icu.text.PluralRules; 
    2937import com.ibm.icu.text.PluralRules.FixedDecimal; 
     
    3240    static TestInfo testInfo = TestInfo.getInstance(); 
    3341    static Info INFO = new Info(); 
     42    private static final boolean THROW = true; 
    3443 
    3544    private static final int SAMPLE_LIMIT = 8; 
     
    201210 
    202211    static class Info { 
     212        enum Type {Warning, Error} 
    203213        Set<String> bounds = new TreeSet(); 
    204214 
    205         public void add(String string) { 
     215        public void add(Type type, String string) { 
    206216            if (string != null && !string.isEmpty()) { 
    207                 bounds.add(string); 
     217                if (THROW && type == Type.Error) { 
     218                    throw new IllegalArgumentException(string); 
     219                } 
     220                bounds.add(type + ": " + string); 
    208221            } 
    209222        } 
     
    227240            this.isInteger = isInteger; 
    228241        } 
    229         public String toString(boolean isKnownBounded, String keyword, String rule) { 
     242        public String toString(boolean isKnownBounded, String keyword, PluralRules rule) { 
    230243            boolean first = false; 
    231244            if (countNoTrailing < 0) { 
     
    250263        } 
    251264 
    252         public boolean computeBoundedWithSize(boolean isKnownBounded, String keyword, String rule, boolean first) { 
     265        public boolean computeBoundedWithSize(boolean isKnownBounded, String keyword, PluralRules rule, boolean first) { 
    253266            boolean isBounded = isKnownBounded || countNoTrailing < UNBOUNDED_LIMIT; 
    254267            if (isBounded != isKnownBounded && first) { 
    255                 INFO.add((isInteger ? "integer" : "decimal")  
    256                         + " computation from rule ≠ from items, rule: " + keyword + ": " + rule  
    257                         + "; count: " + noTrailing); 
     268                Type infoType = noTrailing.size() == 0 && keyword.equals("other") ||  
     269                        noTrailing.size() == 1 && keyword.equals("many") && noTrailing.iterator().next() == 1000000.0d // Welsh 
     270                        ? Info.Type.Warning  
     271                                : Info.Type.Error; 
     272                INFO.add(infoType, (isInteger ? "integer" : "decimal")  
     273                        + " computation from rule ≠ from items" 
     274                        + "; keyword: " + keyword  
     275                        + "; count: " + noTrailing  
     276                        + "; rule: " + rule  
     277                        ); 
    258278            } 
    259279            return isBounded; 
     
    289309    class DataSamples { 
    290310        private final String keyword; // for debugging 
    291         private final String rule; 
     311        private final PluralRules rules; // for debugging 
    292312        private final DataSample integers = new DataSample(true); 
    293313        private final DataSample decimals = new DataSample(false); 
     
    296316        private boolean boundsComputed; 
    297317 
    298         DataSamples(String keyword, String rule) { 
     318        DataSamples(String keyword, PluralRules rules) { 
    299319            this.keyword = keyword; 
    300             this.rule = rule; 
    301             isKnownIntegerBounded = computeBounded(rule, true); 
    302             isKnownDecimalBounded = computeBounded(rule, false); 
     320            this.rules = rules; 
     321            isKnownIntegerBounded = computeBounded(rules.getRules(keyword), true); 
     322            isKnownDecimalBounded = computeBounded(rules.getRules(keyword), false); 
    303323        } 
    304324 
     
    315335        public String toString() { 
    316336            boundsComputed = true; 
    317             String integersString = integers.toString(isKnownIntegerBounded, keyword, rule); 
     337            String integersString = integers.toString(isKnownIntegerBounded, keyword, rules); 
    318338            String decimalsString = type == PluralType.ordinal ? ""  
    319                     : decimals.toString(isKnownDecimalBounded, keyword, rule); 
    320             return (integersString.isEmpty() ? "\t\t" : "\t@integers\t" + integersString) 
    321                     + (decimalsString.isEmpty() ? "" : "\t@decimals\t" + decimalsString); 
     339                    : decimals.toString(isKnownDecimalBounded, keyword, rules); 
     340            return (integersString.isEmpty() ? "\t\t" : "\t@integer\t" + integersString) 
     341                    + (decimalsString.isEmpty() ? "" : "\t@decimal\t" + decimalsString); 
    322342        } 
    323343        @Override 
     
    329349 
    330350    static boolean computeBounded(String orRule, boolean integer) { 
    331         if (orRule == null) { 
     351        if (orRule == null || orRule.isEmpty()) { 
    332352            return false; 
    333353        } 
     
    343363                // check to see that the integer values are bounded and that the decimal values are 
    344364                // once this happens, then the 'and' rule is bounded. 
    345                  
     365 
    346366                // if the fractional parts must be zero, then this rule is empty for decimals (and thus bounded) 
    347367                decBounded |= (operand == 'v' || operand == 'w' || operand == 'f' || operand == 't') 
     
    350370                intBounded |= (operand == 'f' || operand == 't')  
    351371                        && (remainder.equals("is 1") || remainder.equals("is not 0")); // should flesh out with parser 
    352                  
     372 
    353373                if(!atomicRule.contains("mod") && !atomicRule.contains("not")&& !atomicRule.contains("!")) { 
    354374                    intBounded |= operand == 'i' || operand == 'n'; 
     
    426446        String keyword = pluralRules.select(ni); 
    427447 
    428         INFO.add(checkForDuplicates(pluralRules, ni)); 
     448        INFO.add(Info.Type.Warning, checkForDuplicates(pluralRules, ni)); 
    429449        DataSamples data = keywordToData.get(keyword); 
    430450        if (data == null) { 
    431             keywordToData.put(keyword, data = new DataSamples(keyword, pluralInfo.getRule(Count.valueOf(keyword)))); 
     451            keywordToData.put(keyword, data = new DataSamples(keyword, pluralRules)); 
    432452        } 
    433453        data.add(ni); 
     
    442462            } 
    443463        } 
    444         if (keywords.size() != 1) { 
     464        if (!keywords.contains("other") || keywords.size() > 2) { // should be either {other, x} or {other} 
    445465            String message = ""; 
    446466            for (String keywordCheck : keywords) { 
     
    471491        output(".*", CldrUtility.GEN_DIRECTORY + "picker/", "output data directory"), 
    472492        filter(".*", null, "filter locales"), 
    473         xml(null, null, "xml file format"); 
     493        xml(null, null, "xml file format"), 
     494        multiline(null, null, "multiple lines in file"), 
     495        sortNew(null, null, "sort without backwards compatible hack"); 
    474496        // boilerplate 
    475497        final Option option; 
     
    483505        myOptions.parse(MyOptions.filter, args, true); 
    484506 
    485  
    486507        Matcher localeMatcher = !MyOptions.filter.option.doesOccur() ? null : Pattern.compile(MyOptions.filter.option.getValue()).matcher(""); 
    487508        boolean fileFormat = MyOptions.xml.option.doesOccur(); 
    488          
    489          
     509        final boolean multiline = MyOptions.multiline.option.doesOccur(); 
     510        final boolean sortNew = MyOptions.sortNew.option.doesOccur(); 
     511 
     512 
    490513        computeBounded("n is not 0 and n mod 1000000 is 0", false); 
    491514        int failureCount = 0; 
    492515 
    493516        PluralRules pluralRules2 = PluralRules.createRules("one: n is 3..9; two: n is 7..12"); 
    494         checkForDuplicates(pluralRules2 , new FixedDecimal(8)); 
     517        System.out.println("Checking " + checkForDuplicates(pluralRules2 , new FixedDecimal(8))); 
     518        PrintWriter out = null; 
    495519 
    496520        for (PluralType type : PluralType.values()) { 
    497521            if (fileFormat) { 
    498                 WritePluralRules.writePluralHeader(type); 
    499             } 
     522                out = BagFormatter.openUTF8Writer(CldrUtility.GEN_DIRECTORY + "/plurals/",  
     523                        (type == PluralType.cardinal ? "plurals.xml" : "ordinals.xml")); 
     524                out.println(WritePluralRules.formatPluralHeader(type, "GeneratedPluralSamples")); 
     525            } 
     526            System.out.println("\n"); 
    500527            Set<String> locales = testInfo.getSupplementalDataInfo().getPluralLocales(type); 
    501528            Relation<PluralInfo, String> seenAlready = Relation.of(new TreeMap(), TreeSet.class); 
     
    503530            //System.out.println(type + ": " + locales); 
    504531            for (String locale : locales) { 
     532                if (locale.equals("root")) { 
     533                    continue; 
     534                } 
    505535                if (localeMatcher != null && !localeMatcher.reset(locale).find()) { 
    506536                    continue; 
     
    510540            } 
    511541 
     542            // sort if necessary 
     543            Set<Entry<PluralInfo, Set<String>>> sorted = sortNew ? new LinkedHashSet()  
     544            : new TreeSet(new HackComparator(type == PluralType.cardinal  
     545            ? WritePluralRules.HACK_ORDER_PLURALS : WritePluralRules.HACK_ORDER_ORDINALS)); 
     546            for (Entry<PluralInfo, Set<String>> entry : seenAlready.keyValuesSet()) { 
     547                sorted.add(entry); 
     548            } 
     549 
    512550            Relation<GeneratedPluralSamples, PluralInfo> samplesToPlurals = Relation.of(new LinkedHashMap(), LinkedHashSet.class); 
    513             for (Entry<PluralInfo, Set<String>> entry : seenAlready.keyValuesSet()) { 
     551            for (Entry<PluralInfo, Set<String>> entry : sorted) { 
    514552                PluralInfo pluralInfo = entry.getKey(); 
    515553                Set<String> equivalentLocales = entry.getValue(); 
    516554 
    517555                if (fileFormat) { 
    518                     WritePluralRules.writePluralRuleHeader(equivalentLocales); 
     556                    out.println(WritePluralRules.formatPluralRuleHeader(equivalentLocales)); 
     557                    System.out.println(type + "\t" + equivalentLocales); 
    519558                } 
    520559                PluralRules pluralRules = pluralInfo.getPluralRules(); 
     
    524563                    Count count = Count.valueOf(keyword); 
    525564                    String rule = pluralInfo.getRule(count); 
     565                    if (rule != null) { 
     566                        // strip original @... 
     567                        int atPos = rule.indexOf('@'); 
     568                        if (atPos >= 0) { 
     569                            rule = rule.substring(0,atPos).trim(); 
     570                        } 
     571                    } 
    526572                    if (rule == null && count != Count.other) { 
    527573                        pluralInfo.getRule(count); 
     
    539585                    } 
    540586                    if (fileFormat) { 
    541                         String fileRule = ((rule == null ? "" : rule) + data.toString()) 
    542                                 .replace("\t@", "\n                          @").replace('\t', ' '); 
    543                         WritePluralRules.writePluralRule(keyword, fileRule); 
     587                        out.println(WritePluralRules.formatPluralRule(keyword, rule, data.toString(), multiline)); 
    544588                    } else { 
    545589                        System.out.println(data.toString()); 
     
    547591                } 
    548592                if (fileFormat) { 
    549                     WritePluralRules.writePluralRuleFooter(); 
     593                    out.println(WritePluralRules.formatPluralRuleFooter()); 
    550594                } else { 
    551595                    System.out.println(); 
     
    553597            } 
    554598            if (fileFormat) { 
    555                 WritePluralRules.writePluralFooter(); 
     599                out.println(WritePluralRules.formatPluralFooter()); 
    556600            } else { 
    557601                for (Entry<PluralInfo, Set<String>> entry : seenAlready.keyValuesSet()) { 
     
    573617                } 
    574618            } 
     619            System.out.println("\n"); 
     620            if (fileFormat) { 
     621                out.close(); 
     622            } 
    575623        } 
    576624        if (failureCount > 0) { 
     
    579627        INFO.print(); 
    580628    } 
     629 
     630    static class HackComparator implements Comparator<Entry<PluralInfo, Set<String>>> { 
     631        final Map<String, Integer> order; 
     632        HackComparator(Map<String, Integer> order) { 
     633            this.order = order; 
     634        } 
     635        // we get the order of the first items in each of the old rules, and use that order where we can. 
     636        @Override 
     637        public int compare(Entry<PluralInfo, Set<String>> o1, Entry<PluralInfo, Set<String>> o2) { 
     638            Integer firstLocale1 = order.get(o1.getValue().iterator().next()); 
     639            Integer firstLocale2 = order.get(o2.getValue().iterator().next()); 
     640            if (firstLocale1 != null) { 
     641                if (firstLocale2 != null) { 
     642                    return firstLocale1 - firstLocale2; 
     643                } 
     644                return -1; 
     645            } else if (firstLocale2 != null) { 
     646                return 1; 
     647            } else { // only if BOTH are null, use better comparison 
     648                return o1.getKey().compareTo(o2.getKey()); 
     649            } 
     650        } 
     651    } 
     652 
    581653} 
  • trunk/tools/java/org/unicode/cldr/tool/WritePluralRules.java

    r9232 r9236  
    3333            } 
    3434            PluralRules rules = forLocale(locale); 
    35 //            PluralRules existingRules = stringToRules.get(rules.toString()); 
    36 //            if (existingRules == null) { 
    37 //                stringToRules.put(rules.toString(), existingRules = rules); 
    38 //            } 
     35            //            PluralRules existingRules = stringToRules.get(rules.toString()); 
     36            //            if (existingRules == null) { 
     37            //                stringToRules.put(rules.toString(), existingRules = rules); 
     38            //            } 
    3939            rulesToLocales.put(rules, locale); 
    4040        } 
    41         writePluralHeader(PluralType.cardinal); 
     41        System.out.println( 
     42        formatPluralHeader(PluralType.cardinal, "WritePluralRules") 
     43        ); 
    4244        TreeSet<Entry<PluralRules, Set<String>>> sorted = new TreeSet<Entry<PluralRules, Set<String>>>(new HackComparator()); 
    4345        sorted.addAll(rulesToLocales.keyValuesSet()); 
     
    4648            Set<String> values = entry.getValue(); 
    4749            //String comment = hackComments.get(locales); 
    48             writePluralRuleHeader(values); 
     50            System.out.println(formatPluralRuleHeader(values)); 
    4951            for (String keyword : rules.getKeywords()) { 
    5052                String rule = rules.getRules(keyword); 
     
    5254                    continue; 
    5355                } 
    54                 writePluralRule(keyword, rule); 
     56                System.out.println(formatPluralRule(keyword, rule, "", false)); 
    5557            } 
    56             writePluralRuleFooter(); 
     58            System.out.println(formatPluralRuleFooter()); 
    5759            /* 
    5860        <pluralRules locales="ar"> 
     
    6668             */ 
    6769        } 
    68         writePluralFooter(); 
     70        System.out.println(formatPluralFooter()); 
    6971    } 
    7072 
    71     public static void writePluralRuleFooter() { 
    72         System.out.println("        </pluralRules>"); 
     73    public static String formatPluralRuleFooter() { 
     74        return "        </pluralRules>"; 
    7375    } 
    7476 
    75     public static void writePluralRule(String keyword, String rule) { 
    76         System.out.println("            <pluralRule count=\"" + keyword + "\">" + rule + "</pluralRule>"); 
     77    public static String formatPluralRule(String keyword, String rule, String samples, boolean newLine) { 
     78        if (rule == null) { 
     79            rule = ""; 
     80        } 
     81        if (newLine) { 
     82            rule = "\n                " + rule; 
     83            samples = samples.replace("\t@", "\n                @"); 
     84        } 
     85        String result = ("            <pluralRule count=\"" + keyword + "\">"  
     86                + rule  
     87                + samples.replace('\t', ' ')  
     88                + (newLine ? "\n            " : "") 
     89                + "</pluralRule>"); 
     90        return result; 
    7791    } 
    7892 
    79     public static void writePluralRuleHeader(Set<String> values) { 
     93    public static String formatPluralRuleHeader(Set<String> values) { 
    8094        String locales = CollectionUtilities.join(values, " "); 
    81         System.out.println("        <pluralRules locales=\"" + locales + "\">" 
     95        String result = ("        <pluralRules locales=\"" + locales + "\">" 
    8296                //+ (comment != null ? comment : "") 
    8397                ); 
     98        return result; 
    8499    } 
    85100 
    86     public static void writePluralFooter() { 
    87         System.out.println("    </plurals>\n" + 
    88                         "</supplementalData>"); 
     101    public static String formatPluralFooter() { 
     102        return "    </plurals>\n" + 
     103                "</supplementalData>"; 
    89104    } 
    90105 
    91     public static void writePluralHeader(PluralType type) { 
    92         System.out.println( 
    93                 "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" 
    94                         +"<!DOCTYPE supplementalData SYSTEM \"../../common/dtd/ldmlSupplemental.dtd\">\n" 
    95                         +"<!--\n" 
    96                         +"Copyright © 1991-2013 Unicode, Inc.\n" 
    97                         +"CLDR data files are interpreted according to the LDML specification (http://unicode.org/reports/tr35/)\n" 
    98                         +"For terms of use, see http://www.unicode.org/copyright.html\n" 
    99                         +"-->\n" 
    100                         +"<supplementalData>\n" 
    101                         +"    <version number=\"$Revision" + 
    102                         "$\"/>\n" 
    103                         +"    <generation date=\"$Date" + 
    104                         "$\"/>\n" 
    105                         +"    <plurals type=\"" + type + "\">\n" 
    106                         +"        <!-- For a canonicalized list, use WritePluralRules -->\n" 
    107                         +"        <!-- if locale is known to have no plurals, there are no rules -->" 
    108                 ); 
     106    public static String formatPluralHeader(PluralType type, String filename) { 
     107        return "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" 
     108                +"<!DOCTYPE supplementalData SYSTEM \"../../common/dtd/ldmlSupplemental.dtd\">\n" 
     109                +"<!--\n" 
     110                +"Copyright © 1991-2013 Unicode, Inc.\n" 
     111                +"CLDR data files are interpreted according to the LDML specification (http://unicode.org/reports/tr35/)\n" 
     112                +"For terms of use, see http://www.unicode.org/copyright.html\n" 
     113                +"-->\n" 
     114                +"<supplementalData>\n" 
     115                +"    <version number=\"$Revision" + 
     116                "$\"/>\n" 
     117                +"    <generation date=\"$Date" + 
     118                "$\"/>\n" 
     119                +"    <plurals type=\"" + type + "\">\n" 
     120                +"        <!-- For a canonicalized list, use " + filename + " -->\n" 
     121                +"        <!-- if locale is known to have no plurals, there are no rules -->"; 
    109122    } 
    110      
    111 //    static Map<String,String> hackComments = new HashMap<String,String>(); 
    112 //    static { 
    113 //        hackComments.put("ga", " <!-- http://unicode.org/cldr/trac/ticket/3915 -->"); 
    114 //        hackComments.put("mt", " <!-- from Tamplin's data -->"); 
    115 //        hackComments.put("mk", " <!-- from Tamplin's data -->"); 
    116 //        hackComments.put("cy", " <!-- from http://www.saltcymru.org/wordpress/?p=99&lang=en -->"); 
    117 //        hackComments.put("br", " <!-- from http://unicode.org/cldr/trac/ticket/2886 -->"); 
    118 //    } 
    119      
     123 
     124    //    static Map<String,String> hackComments = new HashMap<String,String>(); 
     125    //    static { 
     126    //        hackComments.put("ga", " <!-- http://unicode.org/cldr/trac/ticket/3915 -->"); 
     127    //        hackComments.put("mt", " <!-- from Tamplin's data -->"); 
     128    //        hackComments.put("mk", " <!-- from Tamplin's data -->"); 
     129    //        hackComments.put("cy", " <!-- from http://www.saltcymru.org/wordpress/?p=99&lang=en -->"); 
     130    //        hackComments.put("br", " <!-- from http://unicode.org/cldr/trac/ticket/2886 -->"); 
     131    //    } 
     132 
    120133    static class HackComparator implements Comparator<Entry<PluralRules, Set<String>>> { 
    121134        // we get the order of the first items in each of the old rules, and use that order where we can. 
    122135        PluralRulesComparator prc = new PluralRulesComparator(); 
    123         static Map<String,Integer> hackMap = new HashMap<String,Integer>(); 
    124         static { 
    125             int i = 0; 
    126             for (String s : "az ar he asa af lg vo ak ff lv iu ga ro mo lt be cs sk pl sl mt mk cy lag shi br ksh tzm gv gd".split(" ")) { 
    127                 hackMap.put(s, i++); 
    128             } 
    129         } 
    130136        @Override 
    131137        public int compare(Entry<PluralRules, Set<String>> o1, Entry<PluralRules, Set<String>> o2) { 
    132             Integer firstLocale1 = hackMap.get(o1.getValue().iterator().next()); 
    133             Integer firstLocale2 = hackMap.get(o2.getValue().iterator().next()); 
     138            Integer firstLocale1 = HACK_ORDER_PLURALS.get(o1.getValue().iterator().next()); 
     139            Integer firstLocale2 = HACK_ORDER_PLURALS.get(o2.getValue().iterator().next()); 
    134140            if (firstLocale1 != null) { 
    135141                if (firstLocale2 != null) { 
     
    144150        } 
    145151    } 
    146      
     152 
     153    static Map<String,Integer> HACK_ORDER_PLURALS = new HashMap<String,Integer>(); 
     154    static Map<String,Integer> HACK_ORDER_ORDINALS = new HashMap<String,Integer>(); 
     155    static { 
     156        int i = 0; 
     157        for (String s : "ar he iw af asa ast az bem bez bg brx cgg chr ckb dv ee el eo es eu fo fur fy gsw ha haw hu jgo jmc ka kaj kcg kk kkj kl ks ksb ku ky lb lg mas mgo ml mn nah nb nd ne nn nnh no nr ny nyn om or os pap ps rm rof rwk saq seh sn so sq ss ssy st syr ta te teo tig tk tn tr ts uz ve vo vun wae xh xog ak bh guw ln mg nso pa ti wa ff fr hy kab lv iu kw naq se sma smi smj smn sms ga mo ro lt be cs sk pl sl mt mk cy lag shi br ksh tzm gv gd bm bo dz id in ig ii ja jbo jv jw kde kea km ko lkt lo ms my nqo sah ses sg th to vi wo yo zh fil tl ca de en et fi gl it nl sv sw ur yi ji pt da pt_PT am bn fa gu hi kn mr zu is si bs hr sh sr ru uk".split(" ")) { 
     158            HACK_ORDER_PLURALS.put(s, i++); 
     159        } 
     160        i = 0; 
     161        for (String s : "af fil hu sv en it ca mr gu hi bn zu".split(" ")) { 
     162            HACK_ORDER_ORDINALS.put(s, i++); 
     163        } 
     164    } 
     165 
    147166    static class PluralRulesComparator implements Comparator<PluralRules> { 
    148167        CollectionUtilities.CollectionComparator<String> comp = new CollectionUtilities.CollectionComparator<String>(); 
     
    159178        } 
    160179    } 
    161      
     180 
    162181    static PluralRules forLocale(String locale) { 
    163182        PluralRules override = null; // PluralRulesFactory.getPluralOverrides().get(new ULocale(locale)); 
  • trunk/tools/java/org/unicode/cldr/util/SupplementalDataInfo.java

    r9232 r9236  
    28262826            pluralRulesString = pluralRuleBuilder.toString(); 
    28272827            pluralRules = PluralRules.createRules(pluralRulesString); 
    2828  
     2828            if (pluralRules == null) { 
     2829                throw new IllegalArgumentException("Can't create plurals from <" + pluralRulesString + ">"); 
     2830            } 
    28292831            EnumSet<Count> _keywords = EnumSet.noneOf(Count.class); 
    28302832            for (String s : pluralRules.getKeywords()) { 
Note: See TracChangeset for help on using the changeset viewer.