]> git.saurik.com Git - apple/icu.git/blob - icuSources/data/brkitr/word_POSIX.txt
dbfefaf7b3384c78d34c07f71e55224810b8e73f
[apple/icu.git] / icuSources / data / brkitr / word_POSIX.txt
1 #
2 # Copyright (C) 2002-2015, International Business Machines Corporation
3 # and others. All Rights Reserved.
4 #
5 # file: word_POSIX.txt
6 #
7 # ICU Word Break Rules, POSIX locale.
8 # See Unicode Standard Annex #29.
9 # These rules are based on UAX #29 Revision 22 for Unicode Version 6.3
10 #
11 # Note: Updates to word.txt will usually need to be merged into
12 # word_POSIX.txt also.
13
14 ##############################################################################
15 #
16 # Character class definitions from TR 29
17 #
18 ##############################################################################
19
20 !!chain;
21 !!RINoChain;
22
23
24 #
25 # Character Class Definitions.
26 #
27
28 $CR = [\p{Word_Break = CR}];
29 $LF = [\p{Word_Break = LF}];
30 $Newline = [\p{Word_Break = Newline}];
31 $Extend = [\p{Word_Break = Extend}];
32 $RI = [\p{Word_Break = Regional_Indicator}];
33 $Format = [\p{Word_Break = Format}];
34 $Katakana = [\p{Word_Break = Katakana}];
35 $Hebrew_Letter = [\p{Word_Break = Hebrew_Letter}];
36 $ALetter = [\p{Word_Break = ALetter}];
37 $Single_Quote = [\p{Word_Break = Single_Quote}];
38 $Double_Quote = [\p{Word_Break = Double_Quote}];
39 $MidNumLet = [\p{Word_Break = MidNumLet} - [.]];
40 $MidLetter = [\p{Word_Break = MidLetter} - [\:]];
41 $MidNum = [\p{Word_Break = MidNum} [.]];
42 $Numeric = [\p{Word_Break = Numeric}];
43 $ExtendNumLet = [\p{Word_Break = ExtendNumLet}];
44
45 $Han = [:Han:];
46 $Hiragana = [:Hiragana:];
47
48 # Special character classes for people & body part emoji:
49 # Subsets of $Extend:
50 $ZWJ = \u200D;
51 $EmojiVar = \uFE0F;
52 # The following are subsets of \p{Word_Break = Other}
53 $EmojiForSeqs = [\u2764 \U0001F441 \U0001F466-\U0001F469 \U0001F48B \U0001F5E8];
54 $EmojiForMods = [\u261D \u26F9 \u270A-\u270D \U0001F385 \U0001F3C3-\U0001F3C4 \U0001F3C7 \U0001F3CA-\U0001F3CB \U0001F442-\U0001F443 \U0001F446-\U0001F450 \U0001F466-\U0001F469 \U0001F46E-\U0001F478 \U0001F47C \U0001F481-\U0001F483 \U0001F485-\U0001F487 \U0001F4AA \U0001F590 \U0001F595 \U0001F596 \U0001F645-\U0001F647 \U0001F64B-\U0001F64F \U0001F6A3 \U0001F6B4-\U0001F6B6 \U0001F6C0 \U0001F918];
55 $EmojiMods = [\U0001F3FB-\U0001F3FF];
56
57 # Dictionary character set, for triggering language-based break engines. Currently
58 # limited to LineBreak=Complex_Context. Note that this set only works in Unicode
59 # 5.0 or later as the definition of Complex_Context was corrected to include all
60 # characters requiring dictionary break.
61
62 $Control = [\p{Grapheme_Cluster_Break = Control}];
63 $HangulSyllable = [\uac00-\ud7a3];
64 $ComplexContext = [:LineBreak = Complex_Context:];
65 $KanaKanji = [$Han $Hiragana $Katakana];
66 $dictionaryCJK = [$KanaKanji $HangulSyllable];
67 $dictionary = [$ComplexContext $dictionaryCJK];
68
69 # leave CJK scripts out of ALetterPlus
70 $ALetterPlus = [$ALetter-$dictionaryCJK [$ComplexContext-$Extend-$Control]];
71
72
73 #
74 # Rules 4 Ignore Format and Extend characters,
75 # except when they appear at the beginning of a region of text.
76 #
77 # TODO: check if handling of katakana in dictionary makes rules incorrect/void
78 $KatakanaEx = $Katakana ($Extend | $Format)*;
79 $Hebrew_LetterEx = $Hebrew_Letter ($Extend | $Format)*;
80 $ALetterEx = $ALetterPlus ($Extend | $Format)*;
81 $Single_QuoteEx = $Single_Quote ($Extend | $Format)*;
82 $Double_QuoteEx = $Double_Quote ($Extend | $Format)*;
83 $MidNumLetEx = $MidNumLet ($Extend | $Format)*;
84 $MidLetterEx = $MidLetter ($Extend | $Format)*;
85 $MidNumEx = $MidNum ($Extend | $Format)*;
86 $NumericEx = $Numeric ($Extend | $Format)*;
87 $ExtendNumLetEx = $ExtendNumLet ($Extend | $Format)*;
88
89 $Ideographic = [\p{Ideographic}];
90 $HiraganaEx = $Hiragana ($Extend | $Format)*;
91 $IdeographicEx = $Ideographic ($Extend | $Format)*;
92
93 ## -------------------------------------------------
94
95 !!forward;
96
97
98 # Rule 3 - CR x LF
99 #
100 $CR $LF;
101
102 # Rule 4 - ignore Format and Extend characters, except when they appear at the beginning
103 # of a region of Text. The rule here comes into play when the start of text
104 # begins with a group of Format chars, or with a "word" consisting of a single
105 # char that is not in any of the listed word break categories followed by
106 # format char(s), or is not a CJK dictionary character.
107 [^$CR $LF $Newline]? ($Extend | $Format)+;
108
109 $NumericEx {100};
110 $ALetterEx {200};
111 $HangulSyllable {200};
112 $Hebrew_LetterEx{200};
113 $KatakanaEx {400}; # note: these status values override those from rule 5
114 $HiraganaEx {400}; # by virtue of being numerically larger.
115 $IdeographicEx {400}; #
116
117 #
118 # rule 5
119 # Do not break between most letters.
120 #
121 ($ALetterEx | $Hebrew_LetterEx) ($ALetterEx | $Hebrew_LetterEx) {200};
122
123 # rule 6 and 7
124 ($ALetterEx | $Hebrew_LetterEx) ($MidLetterEx | $MidNumLetEx | $Single_QuoteEx) ($ALetterEx | $Hebrew_LetterEx) {200};
125
126 # rule 7a
127 $Hebrew_LetterEx $Single_QuoteEx {200};
128
129 # rule 7b and 7c
130 $Hebrew_LetterEx $Double_QuoteEx $Hebrew_LetterEx {200};
131
132 # rule 8
133
134 $NumericEx $NumericEx {100};
135
136 # rule 9
137
138 ($ALetterEx | $Hebrew_LetterEx) $NumericEx {200};
139
140 # rule 10
141
142 $NumericEx ($ALetterEx | $Hebrew_LetterEx) {200};
143
144 # rule 11 and 12
145
146 $NumericEx ($MidNumEx | $MidNumLetEx | $Single_QuoteEx) $NumericEx {100};
147
148 # rule 13
149 # to be consistent with $KanaKanji $KanaKanhi, changed
150 # from 300 to 400.
151 # See also TestRuleStatus in intltest/rbbiapts.cpp
152 $KatakanaEx $KatakanaEx {400};
153
154 # rule 13a/b
155
156 $ALetterEx $ExtendNumLetEx {200}; # (13a)
157 $Hebrew_LetterEx $ExtendNumLetEx {200}; # (13a)
158 $NumericEx $ExtendNumLetEx {100}; # (13a)
159 $KatakanaEx $ExtendNumLetEx {400}; # (13a)
160 $ExtendNumLetEx $ExtendNumLetEx {200}; # (13a)
161
162 $ExtendNumLetEx $ALetterEx {200}; # (13b)
163 $ExtendNumLetEx $Hebrew_Letter {200}; # (13b)
164 $ExtendNumLetEx $NumericEx {100}; # (13b)
165 $ExtendNumLetEx $KatakanaEx {400}; # (13b)
166
167 # rule 13c
168
169 $RI $RI $Extend* / $RI;
170 $RI $RI $Extend*;
171
172 # Special forward rules for people & body part emoji:
173 # don't break $ZWJ from subsequent $EmojiForSeqs; don't break between relevant emoji and $EmojiMods
174 $ZWJ $EmojiForSeqs;
175 $EmojiForMods $EmojiVar? $EmojiMods;
176
177 # special handling for CJK characters: chain for later dictionary segmentation
178 $HangulSyllable $HangulSyllable {200};
179 $KanaKanji $KanaKanji {400}; # different rule status if both kana and kanji found
180
181
182 ## -------------------------------------------------
183
184 !!reverse;
185
186 $BackHebrew_LetterEx = ($Format | $Extend)* $Hebrew_Letter;
187 $BackALetterEx = ($Format | $Extend)* $ALetterPlus;
188 $BackSingle_QuoteEx = ($Format | $Extend)* $Single_Quote;
189 $BackDouble_QuoteEx = ($Format | $Extend)* $Double_Quote;
190 $BackMidNumLetEx = ($Format | $Extend)* $MidNumLet;
191 $BackNumericEx = ($Format | $Extend)* $Numeric;
192 $BackMidNumEx = ($Format | $Extend)* $MidNum;
193 $BackMidLetterEx = ($Format | $Extend)* $MidLetter;
194 $BackKatakanaEx = ($Format | $Extend)* $Katakana;
195 $BackHiraganaEx = ($Format | $Extend)* $Hiragana;
196 $BackExtendNumLetEx = ($Format | $Extend)* $ExtendNumLet;
197
198 # rule 3
199 $LF $CR;
200
201 # rule 4
202 ($Format | $Extend)* [^$CR $LF $Newline]?;
203
204 # rule 5
205
206 ($BackALetterEx | $BackHebrew_LetterEx) ($BackALetterEx | $BackHebrew_LetterEx);
207
208 # rule 6 and 7
209
210 ($BackALetterEx | $BackHebrew_LetterEx) ($BackMidLetterEx | $BackMidNumLetEx | $BackSingle_QuoteEx) ($BackALetterEx | $BackHebrew_LetterEx);
211
212 # rule 7a
213 $BackSingle_QuoteEx $BackHebrew_LetterEx;
214
215 # Rule 7b and 7c
216 $BackHebrew_LetterEx $BackDouble_QuoteEx $BackHebrew_LetterEx;
217
218 # rule 8
219
220 $BackNumericEx $BackNumericEx;
221
222 # rule 9
223
224 $BackNumericEx ($BackALetterEx | $BackHebrew_LetterEx);
225
226 # rule 10
227
228 ($BackALetterEx | $BackHebrew_LetterEx) $BackNumericEx;
229
230 # rule 11 and 12
231
232 $BackNumericEx ($BackMidNumEx | $BackMidNumLetEx | $BackSingle_QuoteEx) $BackNumericEx;
233
234 # rule 13
235
236 $BackKatakanaEx $BackKatakanaEx;
237
238 # rules 13 a/b
239 #
240 $BackExtendNumLetEx ($BackALetterEx | $BackHebrew_LetterEx | $BackNumericEx | $BackKatakanaEx | $BackExtendNumLetEx);
241 ($BackALetterEx | $BackHebrew_LetterEx | $BackNumericEx | $BackKatakanaEx) $BackExtendNumLetEx;
242
243 # rule 13c
244
245 $Extend* $RI $RI / $Extend* $RI $RI;
246 $Extend* $RI $RI;
247
248 # Special reverse rules for people & body part emoji:
249 # don't break $ZWJ from subsequent $EmojiForSeqs; don't break between relevant emoji and $EmojiMods
250 $EmojiForSeqs $ZWJ;
251 $EmojiMods $EmojiVar? $EmojiForMods;
252
253 # special handling for CJK characters: chain for later dictionary segmentation
254 $HangulSyllable $HangulSyllable;
255 $KanaKanji $KanaKanji; #different rule status if both kanji and kana found
256
257 ## -------------------------------------------------
258
259 !!safe_reverse;
260
261 # rule 3
262 ($Extend | $Format)+ .?;
263
264 # rule 6
265 ($MidLetter | $MidNumLet | $Single_Quote) ($BackALetterEx | $BackHebrew_LetterEx);
266
267 # rule 7b
268 $Double_Quote $BackHebrew_LetterEx;
269
270
271 # rule 11
272 ($MidNum | $MidNumLet | $Single_Quote) $BackNumericEx;
273
274 $RI $RI+;
275 # For dictionary-based break
276 $dictionary $dictionary;
277
278 ## -------------------------------------------------
279
280 !!safe_forward;
281
282 # rule 4
283 ($Extend | $Format)+ .?;
284
285 # rule 6
286 ($MidLetterEx | $MidNumLetEx | $Single_QuoteEx) ($ALetterEx | $Hebrew_LetterEx);
287
288 # rule 7b
289 $Double_QuoteEx $Hebrew_LetterEx;
290
291 # rule 11
292 ($MidNumEx | $MidNumLetEx | $Single_QuoteEx) $NumericEx;
293
294 $RI $RI+;
295 # For dictionary-based break
296 $dictionary $dictionary;