]>
Commit | Line | Data |
---|---|---|
b75a7d8f | 1 | # |
4388f060 | 2 | # Copyright (C) 2002-2011, International Business Machines Corporation |
374ca955 | 3 | # and others. All Rights Reserved. |
b75a7d8f | 4 | # |
374ca955 | 5 | # file: word.txt |
b75a7d8f | 6 | # |
374ca955 | 7 | # ICU Word Break Rules |
b75a7d8f | 8 | # See Unicode Standard Annex #29. |
4388f060 | 9 | # These rules are based on UAX #29 Revision 19 for Unicode Version 6.1 |
b75a7d8f | 10 | # |
73c04bcf A |
11 | # Note: Updates to word.txt will usually need to be merged into |
12 | # word_POSIX.txt and word_ja.txt also. | |
b75a7d8f | 13 | |
374ca955 | 14 | ############################################################################## |
b75a7d8f A |
15 | # |
16 | # Character class definitions from TR 29 | |
17 | # | |
374ca955 A |
18 | ############################################################################## |
19 | ||
20 | !!chain; | |
21 | ||
b75a7d8f A |
22 | |
23 | # | |
24 | # Character Class Definitions. | |
b75a7d8f | 25 | # |
b75a7d8f | 26 | |
46f4442e A |
27 | $CR = [\p{Word_Break = CR}]; |
28 | $LF = [\p{Word_Break = LF}]; | |
29 | $Newline = [\p{Word_Break = Newline}]; | |
30 | $Extend = [\p{Word_Break = Extend}]; | |
73c04bcf | 31 | $Format = [\p{Word_Break = Format}]; |
46f4442e | 32 | $Katakana = [\p{Word_Break = Katakana}]; |
73c04bcf | 33 | $ALetter = [\p{Word_Break = ALetter}]; |
46f4442e | 34 | $MidNumLet = [\p{Word_Break = MidNumLet}]; |
73c04bcf A |
35 | $MidLetter = [\p{Word_Break = MidLetter}]; |
36 | $MidNum = [\p{Word_Break = MidNum}]; | |
37 | $Numeric = [\p{Word_Break = Numeric}]; | |
38 | $ExtendNumLet = [\p{Word_Break = ExtendNumLet}]; | |
39 | ||
40 | ||
73c04bcf A |
41 | # Dictionary character set, for triggering language-based break engines. Currently |
42 | # limited to LineBreak=Complex_Context. Note that this set only works in Unicode | |
43 | # 5.0 or later as the definition of Complex_Context was corrected to include all | |
44 | # characters requiring dictionary break. | |
45 | ||
46 | $dictionary = [:LineBreak = Complex_Context:]; | |
46f4442e A |
47 | $Control = [\p{Grapheme_Cluster_Break = Control}]; |
48 | $ALetterPlus = [$ALetter [$dictionary-$Extend-$Control]]; # Note: default ALetter does not | |
49 | # include the dictionary characters. | |
73c04bcf A |
50 | |
51 | # | |
46f4442e A |
52 | # Rules 4 Ignore Format and Extend characters, |
53 | # except when they appear at the beginning of a region of text. | |
73c04bcf A |
54 | # |
55 | $KatakanaEx = $Katakana ($Extend | $Format)*; | |
56 | $ALetterEx = $ALetterPlus ($Extend | $Format)*; | |
46f4442e | 57 | $MidNumLetEx = $MidNumLet ($Extend | $Format)*; |
73c04bcf A |
58 | $MidLetterEx = $MidLetter ($Extend | $Format)*; |
59 | $MidNumEx = $MidNum ($Extend | $Format)*; | |
60 | $NumericEx = $Numeric ($Extend | $Format)*; | |
61 | $ExtendNumLetEx = $ExtendNumLet ($Extend | $Format)*; | |
62 | ||
46f4442e A |
63 | $Hiragana = [\p{script=Hiragana}]; |
64 | $Ideographic = [\p{Ideographic}]; | |
73c04bcf A |
65 | $HiraganaEx = $Hiragana ($Extend | $Format)*; |
66 | $IdeographicEx = $Ideographic ($Extend | $Format)*; | |
b75a7d8f | 67 | |
374ca955 | 68 | ## ------------------------------------------------- |
b75a7d8f | 69 | |
374ca955 | 70 | !!forward; |
b75a7d8f | 71 | |
b75a7d8f | 72 | |
73c04bcf | 73 | # Rule 3 - CR x LF |
46f4442e A |
74 | # |
75 | $CR $LF; | |
73c04bcf A |
76 | |
77 | # Rule 4 - ignore Format and Extend characters, except when they appear at the beginning | |
78 | # of a region of Text. The rule here comes into play when the start of text | |
79 | # begins with a group of Format chars, or with a "word" consisting of a single | |
80 | # char that is not in any of the listed word break categories followed by | |
81 | # format char(s). | |
46f4442e | 82 | [^$CR $LF $Newline]? ($Extend | $Format)+; |
b75a7d8f | 83 | |
374ca955 A |
84 | $NumericEx {100}; |
85 | $ALetterEx {200}; | |
46f4442e A |
86 | $KatakanaEx {300}; # note: these status values override those from rule 5 |
87 | $HiraganaEx {300}; # by virtual of being numerically larger. | |
88 | $IdeographicEx {400}; # | |
b75a7d8f | 89 | |
46f4442e | 90 | # |
374ca955 | 91 | # rule 5 |
46f4442e A |
92 | # Do not break between most letters. |
93 | # | |
73c04bcf | 94 | $ALetterEx $ALetterEx {200}; |
b75a7d8f | 95 | |
374ca955 | 96 | # rule 6 and 7 |
46f4442e | 97 | $ALetterEx ($MidLetterEx | $MidNumLetEx) $ALetterEx {200}; |
b75a7d8f | 98 | |
374ca955 | 99 | # rule 8 |
b75a7d8f | 100 | |
73c04bcf | 101 | $NumericEx $NumericEx {100}; |
b75a7d8f | 102 | |
374ca955 | 103 | # rule 9 |
b75a7d8f | 104 | |
46f4442e | 105 | $ALetterEx $NumericEx {200}; |
b75a7d8f | 106 | |
374ca955 | 107 | # rule 10 |
b75a7d8f | 108 | |
73c04bcf | 109 | $NumericEx $ALetterEx {200}; |
b75a7d8f | 110 | |
374ca955 A |
111 | # rule 11 and 12 |
112 | ||
46f4442e | 113 | $NumericEx ($MidNumEx | $MidNumLetEx) $NumericEx {100}; |
374ca955 A |
114 | |
115 | # rule 13 | |
116 | ||
73c04bcf | 117 | $KatakanaEx $KatakanaEx {300}; |
374ca955 A |
118 | |
119 | # rule 13a/b | |
120 | ||
73c04bcf A |
121 | $ALetterEx $ExtendNumLetEx {200}; # (13a) |
122 | $NumericEx $ExtendNumLetEx {100}; # (13a) | |
123 | $KatakanaEx $ExtendNumLetEx {300}; # (13a) | |
46f4442e | 124 | $ExtendNumLetEx $ExtendNumLetEx {200}; # (13a) |
374ca955 | 125 | |
73c04bcf A |
126 | $ExtendNumLetEx $ALetterEx {200}; # (13b) |
127 | $ExtendNumLetEx $NumericEx {100}; # (13b) | |
128 | $ExtendNumLetEx $KatakanaEx {300}; # (13b) | |
374ca955 A |
129 | |
130 | ||
131 | ||
132 | ## ------------------------------------------------- | |
b75a7d8f | 133 | |
374ca955 A |
134 | !!reverse; |
135 | ||
73c04bcf | 136 | $BackALetterEx = ($Format | $Extend)* $ALetterPlus; |
46f4442e | 137 | $BackMidNumLetEx = ($Format | $Extend)* $MidNumLet; |
73c04bcf A |
138 | $BackNumericEx = ($Format | $Extend)* $Numeric; |
139 | $BackMidNumEx = ($Format | $Extend)* $MidNum; | |
140 | $BackMidLetterEx = ($Format | $Extend)* $MidLetter; | |
141 | $BackKatakanaEx = ($Format | $Extend)* $Katakana; | |
142 | $BackExtendNumLetEx= ($Format | $Extend)* $ExtendNumLet; | |
374ca955 | 143 | |
73c04bcf | 144 | # rule 3 |
46f4442e | 145 | $LF $CR; |
374ca955 | 146 | |
73c04bcf | 147 | # rule 4 |
46f4442e | 148 | ($Format | $Extend)* [^$CR $LF $Newline]?; |
374ca955 A |
149 | |
150 | # rule 5 | |
151 | ||
73c04bcf | 152 | $BackALetterEx $BackALetterEx; |
374ca955 A |
153 | |
154 | # rule 6 and 7 | |
155 | ||
46f4442e | 156 | $BackALetterEx ($BackMidLetterEx | $BackMidNumLetEx) $BackALetterEx; |
374ca955 A |
157 | |
158 | ||
159 | # rule 8 | |
160 | ||
73c04bcf | 161 | $BackNumericEx $BackNumericEx; |
374ca955 A |
162 | |
163 | # rule 9 | |
164 | ||
73c04bcf | 165 | $BackNumericEx $BackALetterEx; |
374ca955 A |
166 | |
167 | # rule 10 | |
168 | ||
73c04bcf | 169 | $BackALetterEx $BackNumericEx; |
374ca955 A |
170 | |
171 | # rule 11 and 12 | |
172 | ||
46f4442e | 173 | $BackNumericEx ($BackMidNumEx | $BackMidNumLetEx) $BackNumericEx; |
374ca955 A |
174 | |
175 | # rule 13 | |
176 | ||
73c04bcf | 177 | $BackKatakanaEx $BackKatakanaEx; |
374ca955 A |
178 | |
179 | # rules 13 a/b | |
b75a7d8f | 180 | # |
46f4442e A |
181 | $BackExtendNumLetEx ($BackALetterEx | $BackNumericEx | $BackKatakanaEx | $BackExtendNumLetEx); |
182 | ($BackALetterEx | $BackNumericEx | $BackKatakanaEx) $BackExtendNumLetEx; | |
374ca955 A |
183 | |
184 | ## ------------------------------------------------- | |
185 | ||
186 | !!safe_reverse; | |
187 | ||
188 | # rule 3 | |
73c04bcf | 189 | ($Extend | $Format)+ .?; |
374ca955 A |
190 | |
191 | # rule 6 | |
46f4442e | 192 | ($MidLetter | $MidNumLet) $BackALetterEx; |
374ca955 A |
193 | |
194 | # rule 11 | |
46f4442e | 195 | ($MidNum | $MidNumLet) $BackNumericEx; |
73c04bcf A |
196 | |
197 | # For dictionary-based break | |
198 | $dictionary $dictionary; | |
374ca955 A |
199 | |
200 | ## ------------------------------------------------- | |
201 | ||
202 | !!safe_forward; | |
203 | ||
374ca955 | 204 | # rule 4 |
73c04bcf | 205 | ($Extend | $Format)+ .?; |
374ca955 A |
206 | |
207 | # rule 6 | |
46f4442e | 208 | ($MidLetterEx | $MidNumLetEx) $ALetterEx; |
b75a7d8f | 209 | |
374ca955 | 210 | # rule 11 |
46f4442e | 211 | ($MidNumEx | $MidNumLetEx) $NumericEx; |
73c04bcf A |
212 | |
213 | # For dictionary-based break | |
214 | $dictionary $dictionary; |