]> git.saurik.com Git - apple/icu.git/blame - icuSources/test/testdata/word_urbTokTest.txt
ICU-59131.0.1.tar.gz
[apple/icu.git] / icuSources / test / testdata / word_urbTokTest.txt
CommitLineData
f3c0d7a5
A
1#
2# Copyright (C) 2016 and later: Unicode, Inc. and others.
3# License & terms of use: http://www.unicode.org/copyright.html
4# Copyright (C) 2002-2016, International Business Machines Corporation
5# and others. All Rights Reserved.
6#
7# file: word_urbTokTest.txt
8#
9# ICU Word Break Rules
10# See Unicode Standard Annex #29.
11# These rules are based on UAX #29 Revision 29 for Unicode Version 9.0
12# with additions for Emoji Sequences from https://goo.gl/cluFCn
13# Also modified with additions for testing urbtok_ functions.
14#
15
16##############################################################################
17#
18# Character class definitions from TR 29
19#
20##############################################################################
21
22!!chain;
23
24# Smart Tokenizer customization
25
26$Space = [\u0020];
27$Fullstop = [\u002E\uFE52\uFF0E];
28$Dash = [\u002D\uFE63\uFF0D];
29
30$Terminators = [\u0021\u00A1\u00A1\u01C3\u01C3\u01C3\u203C\u2048\uFE15\uFF01\u003F];
31$Parenthesis = [\u0028\u005B\u007B\u0029\u005D\u007D];
32$Punctuation = [\u007E\u003D\u002A\u003C\u003E];
33$OtherSingle = [\u0060\u0300\u030F];
34
35$Hash = [\u0023 \uFE5F \uFF03];
36$At = [\u0040 \uFE6B \uFF20];
37$Dollar = [\u0024];
38
39$Semicolon = [\u003B];
40$Colon = [\u003A];
41
42#
43# Character Class Definitions.
44#
45
46$CR = [\p{Word_Break = CR}];
47$LF = [\p{Word_Break = LF}];
48$Newline = [\p{Word_Break = Newline}];
49$Extend = [\p{Word_Break = Extend}];
50$ZWJ = [\p{Word_Break = ZWJ}];
51$Regional_Indicator = [\p{Word_Break = Regional_Indicator}];
52$Format = [\p{Word_Break = Format}];
53$Katakana = [\p{Word_Break = Katakana}];
54$Hebrew_Letter = [\p{Word_Break = Hebrew_Letter}];
55$ALetter = [\p{Word_Break = ALetter}];
56$Single_Quote = [\p{Word_Break = Single_Quote}\u2018\u2019];
57$Double_Quote = [\p{Word_Break = Double_Quote}];
58$MidNumLet = [\p{Word_Break = MidNumLet}-[$Fullstop $Single_Quote]];
59$MidLetter = [\p{Word_Break = MidLetter}-[$Single_Quote]];
60$MidNum = [\p{Word_Break = MidNum}];
61$Numeric = [\p{Word_Break = Numeric}];
62$ExtendNumLet = [\p{Word_Break = ExtendNumLet}];
63$E_Base = [\p{Word_Break = EB}\U0001F3C2\U0001F3C7\U0001F3CC\U0001F46A-\U0001F46D\U0001F46F\U0001F574\U0001F6CC];
64$E_Modifier = [\p{Word_Break = EM}];
65
66# Data for Extended Pictographic scraped from CLDR common/properties/ExtendedPictographic.txt, r12773
67$Extended_Pict = [\U0001F774-\U0001F77F\u2700-\u2701\u2703-\u2704\u270E\u2710-\u2711\u2765-\u2767\U0001F030-\U0001F093\U0001F094-\U0001F09F\U0001F10D-\U0001F10F\U0001F12F\U0001F16C-\U0001F16F\U0001F1AD-\U0001F1E5\U0001F203-\U0001F20F\U0001F23C-\U0001F23F\U0001F249-\U0001F24F\U0001F252-\U0001F2FF\U0001F7D5-\U0001F7FF\U0001F000-\U0001F003\U0001F005-\U0001F02B\U0001F02C-\U0001F02F\U0001F322-\U0001F323\U0001F394-\U0001F395\U0001F398\U0001F39C-\U0001F39D\U0001F3F1-\U0001F3F2\U0001F3F6\U0001F4FE\U0001F53E-\U0001F548\U0001F54F\U0001F568-\U0001F56E\U0001F571-\U0001F572\U0001F57B-\U0001F586\U0001F588-\U0001F589\U0001F58E-\U0001F58F\U0001F591-\U0001F594\U0001F597-\U0001F5A3\U0001F5A6-\U0001F5A7\U0001F5A9-\U0001F5B0\U0001F5B3-\U0001F5BB\U0001F5BD-\U0001F5C1\U0001F5C5-\U0001F5D0\U0001F5D4-\U0001F5DB\U0001F5DF-\U0001F5E0\U0001F5E2\U0001F5E4-\U0001F5E7\U0001F5E9-\U0001F5EE\U0001F5F0-\U0001F5F2\U0001F5F4-\U0001F5F9\u2605\u2607-\u260D\u260F-\u2610\u2612\u2616-\u2617\u2619-\u261C\u261E-\u261F\u2621\u2624-\u2625\u2627-\u2629\u262B-\u262D\u2630-\u2637\u263B-\u2647\u2654-\u265F\u2661-\u2662\u2664\u2667\u2669-\u267A\u267C-\u267E\u2680-\u2691\u2695\u2698\u269A\u269D-\u269F\u26A2-\u26A9\u26AC-\u26AF\u26B2-\u26BC\u26BF-\u26C3\u26C6-\u26C7\u26C9-\u26CD\u26D0\u26D2\u26D5-\u26E8\u26EB-\u26EF\u26F6\u26FB-\u26FC\u26FE-\u26FF\u2388\U0001FA00-\U0001FFFD\U0001F0A0-\U0001F0AE\U0001F0B1-\U0001F0BF\U0001F0C1-\U0001F0CF\U0001F0D1-\U0001F0F5\U0001F0AF-\U0001F0B0\U0001F0C0\U0001F0D0\U0001F0F6-\U0001F0FF\U0001F80C-\U0001F80F\U0001F848-\U0001F84F\U0001F85A-\U0001F85F\U0001F888-\U0001F88F\U0001F8AE-\U0001F8FF\U0001F900-\U0001F90F\U0001F91F\U0001F928-\U0001F92F\U0001F931-\U0001F932\U0001F93F\U0001F94C-\U0001F94F\U0001F95F-\U0001F97F\U0001F992-\U0001F9BF\U0001F9C1-\U0001F9FF\U0001F6C6-\U0001F6CA\U0001F6E6-\U0001F6E8\U0001F6EA\U0001F6F1-\U0001F6F2\U0001F6D3-\U0001F6DF\U0001F6ED-\U0001F6EF\U0001F6F7-\U0001F6FF];
68$EBG = [\p{Word_Break = EBG}];
69$EmojiNRK = [[\p{Emoji}] - [\p{Word_Break = Regional_Indicator}\u002a\u00230-9©®™〰〽]];
70
71$Han = [:Han:];
72$Hiragana = [:Hiragana:];
73
74
75# Dictionary character set, for triggering language-based break engines. Currently
76# limited to LineBreak=Complex_Context. Note that this set only works in Unicode
77# 5.0 or later as the definition of Complex_Context was corrected to include all
78# characters requiring dictionary break.
79
80$Control = [\p{Grapheme_Cluster_Break = Control}];
81$HangulSyllable = [\uac00-\ud7a3];
82$ComplexContext = [:LineBreak = Complex_Context:];
83$KanaKanji = [$Han $Hiragana $Katakana];
84$dictionaryCJK = [$KanaKanji $HangulSyllable];
85$dictionary = [$ComplexContext $dictionaryCJK];
86
87# leave CJK scripts out of ALetterPlus
88$ALetterPlus = [$ALetter-$dictionaryCJK [$ComplexContext-$Extend-$Control]];
89
90
91#
92# Rules 4 Ignore Format and Extend characters,
93# except when they appear at the beginning of a region of text.
94#
95# TODO: check if handling of katakana in dictionary makes rules incorrect/void
96$KatakanaEx = $Katakana ($Extend | $Format | $ZWJ)*;
97$Hebrew_LetterEx = $Hebrew_Letter ($Extend | $Format | $ZWJ)*;
98$ALetterEx = $ALetterPlus ($Extend | $Format | $ZWJ)*;
99$Single_QuoteEx = $Single_Quote ($Extend | $Format | $ZWJ)*;
100$Double_QuoteEx = $Double_Quote ($Extend | $Format | $ZWJ)*;
101$MidNumLetEx = $MidNumLet ($Extend | $Format | $ZWJ)*;
102$MidLetterEx = $MidLetter ($Extend | $Format | $ZWJ)*;
103$MidNumEx = $MidNum ($Extend | $Format | $ZWJ)*;
104$NumericEx = $Numeric ($Extend | $Format | $ZWJ)*;
105$ExtendNumLetEx = $ExtendNumLet ($Extend | $Format | $ZWJ)*;
106$Regional_IndicatorEx = $Regional_Indicator ($Extend | $Format | $ZWJ)*;
107
108$Ideographic = [\p{Ideographic}];
109$HiraganaEx = $Hiragana ($Extend | $Format | $ZWJ)*;
110$IdeographicEx = $Ideographic ($Extend | $Format | $ZWJ)*;
111
112$Letter = [A-Za-z];
113
114## -------------------------------------------------
115
116!!forward;
117
118# Rule 3 - CR x LF
119#
120$CR $LF;
121
122# Rule 3c ZWJ x (Extended_Pict | EmojiNRK). Precedes WB4, so no intervening Extend chars allowed.
123#
124$ZWJ ($Extended_Pict | $EmojiNRK);
125
126
127# Rule 4 - ignore Format and Extend characters, except when they appear at the beginning
128# of a region of Text. The rule here comes into play when the start of text
129# begins with a group of Format chars, or with a "word" consisting of a single
130# char that is not in any of the listed word break categories followed by
131# format char(s), or is not a CJK dictionary character.
132[^$CR $LF $Newline]? ($Extend | $Format | $ZWJ)+;
133
134$NumericEx {100};
135$ALetterEx {200};
136$HangulSyllable {200};
137$Hebrew_LetterEx{200};
138$KatakanaEx {400}; # note: these status values override those from rule 5
139$HiraganaEx {400}; # by virtue of being numerically larger.
140$IdeographicEx {400}; #
141
142$E_Base ($Extend | $Format | $ZWJ)*;
143$E_Modifier ($Extend | $Format | $ZWJ)*;
144$Extended_Pict ($Extend | $Format | $ZWJ)*;
145
146#
147# rule 5
148# Do not break between most letters.
149#
150($ALetterEx | $Hebrew_LetterEx) ($ALetterEx | $Hebrew_LetterEx) {200};
151
152# rule 6 and 7
153($ALetterEx | $Hebrew_LetterEx) ($MidLetterEx | $MidNumLetEx ) ($ALetterEx | $Hebrew_LetterEx) {200};
154
155# rule 7a
156$Hebrew_LetterEx $Single_QuoteEx {200};
157
158# rule 7b and 7c
159$Hebrew_LetterEx $Double_QuoteEx $Hebrew_LetterEx {200};
160
161# rule 8
162
163$NumericEx $NumericEx {100};
164
165# rule 9
166
167($ALetterEx | $Hebrew_LetterEx) $NumericEx {200};
168
169# rule 10
170
171$NumericEx ($ALetterEx | $Hebrew_LetterEx) {200};
172
173# rule 11 and 12
174
175$NumericEx ($MidNumEx | $MidNumLetEx | $Single_QuoteEx) $NumericEx {100};
176
177# rule 13
178# to be consistent with $KanaKanji $KanaKanhi, changed
179# from 300 to 400.
180# See also TestRuleStatus in intltest/rbbiapts.cpp
181$KatakanaEx $KatakanaEx {400};
182
183# rule 13a/b
184
185$ALetterEx $ExtendNumLetEx {200}; # (13a)
186$Hebrew_LetterEx $ExtendNumLetEx {200}; # (13a)
187$NumericEx $ExtendNumLetEx {100}; # (13a)
188$KatakanaEx $ExtendNumLetEx {400}; # (13a)
189$ExtendNumLetEx $ExtendNumLetEx {200}; # (13a)
190
191$ExtendNumLetEx $ALetterEx {200}; # (13b)
192$ExtendNumLetEx $Hebrew_Letter {200}; # (13b)
193$ExtendNumLetEx $NumericEx {100}; # (13b)
194$ExtendNumLetEx $KatakanaEx {400}; # (13b)
195
196# rule 14
197# Do not break within emoji modifier sequences
198
199($E_Base | $EBG) ($Format | $Extend | $ZWJ)* $E_Modifier;
200
201# rules 15 - 17
202# Pairs of Regional Indicators stay together.
203# With rule chaining disabled by ^, this rule will match exactly two of them.
204# No other rule begins with a Regional_Indicator, so chaining cannot extend the match.
205#
206^$Regional_IndicatorEx $Regional_IndicatorEx;
207
208# special handling for CJK characters: chain for later dictionary segmentation
209$HangulSyllable $HangulSyllable {200};
210$KanaKanji $KanaKanji {400}; # different rule status if both kana and kanji found
211
212$Space* {1};
213$Newline* {2};
214
215$Fullstop {20};
216$Dash {21};
217$Single_Quote {22};
218
219$Contraction = (N | n) $Single_Quote (T | t);
220$Contraction2 = (N | n) $Single_Quote (T | t) $Single_Quote (V | v) (E | e);
221$Contraction3 = (Y | y) $Single_Quote (A | a) (L | l) (L | l);
222
223$Time = (0 | 1 | 2)? $Numeric $Colon (0 | 1 | 2 | 3 | 4 | 5) $Numeric;
224$IPAddress = $Numeric? $Numeric? $Numeric $Fullstop $Numeric? $Numeric? $Numeric;
225
226(N | n) $Single_Quote (T | t) {202};
227(Y | y) $Single_Quote (A | a) (L | l)* {202};
228
229$Fullstop $Fullstop ($Fullstop*) {40};
230$Dash $Dash ($Dash*) {40};
231$Terminators $Terminators ($Terminators*) {40};
232$Punctuation $Punctuation ($Punctuation*) {40};
233$OtherSingle $OtherSingle ($OtherSingle*) {40};
234
235$Single_Quote $Single_Quote {40};
236$Single_Quote $Single_Quote $Single_Quote* {40};
237
238$Hash ($ALetter | $Numeric)* {30};
239$At ($ALetter | $Numeric)* {31};
240$Dollar $ALetter ($ALetter | $Numeric)* {31};
241
242$Time {50};
243$IPAddress {51};
244
245$ALetter / $IPAddress;
246$ALetter / $Time;
247
248($Colon | $Semicolon) $Parenthesis {32};
249
250## -------------------------------------------------
251
252!!reverse;
253
254$BackHebrew_LetterEx = ($Format | $Extend | $ZWJ)* $Hebrew_Letter;
255$BackALetterEx = ($Format | $Extend | $ZWJ)* $ALetterPlus;
256$BackSingle_QuoteEx = ($Format | $Extend | $ZWJ)* $Single_Quote;
257$BackDouble_QuoteEx = ($Format | $Extend | $ZWJ)* $Double_Quote;
258$BackMidNumLetEx = ($Format | $Extend | $ZWJ)* $MidNumLet;
259$BackNumericEx = ($Format | $Extend | $ZWJ)* $Numeric;
260$BackMidNumEx = ($Format | $Extend | $ZWJ)* $MidNum;
261$BackMidLetterEx = ($Format | $Extend | $ZWJ)* $MidLetter;
262$BackKatakanaEx = ($Format | $Extend | $ZWJ)* $Katakana;
263$BackHiraganaEx = ($Format | $Extend | $ZWJ)* $Hiragana;
264$BackExtendNumLetEx = ($Format | $Extend | $ZWJ)* $ExtendNumLet;
265$BackRegional_IndicatorEx = ($Format | $Extend | $ZWJ)* $Regional_Indicator;
266
267# rule 3
268$LF $CR;
269
270# Rule 3c ZWJ x (Extended_Pict | EmojiNRK). Precedes WB4, so no intervening Extend chars allowed.
271#
272($Extended_Pict | $EmojiNRK) $ZWJ;
273
274# rule 4
275($Format | $Extend | $ZWJ)* [^$CR $LF $Newline]?;
276
277# rule 5
278
279($BackALetterEx | $BackHebrew_LetterEx) ($BackALetterEx | $BackHebrew_LetterEx);
280
281# rule 6 and 7
282
283($BackALetterEx | $BackHebrew_LetterEx) ($BackMidLetterEx | $BackMidNumLetEx ) ($BackALetterEx | $BackHebrew_LetterEx);
284
285# rule 7a
286$BackSingle_QuoteEx $BackHebrew_LetterEx;
287
288# Rule 7b and 7c
289$BackHebrew_LetterEx $BackDouble_QuoteEx $BackHebrew_LetterEx;
290
291# rule 8
292
293$BackNumericEx $BackNumericEx;
294
295# rule 9
296
297$BackNumericEx ($BackALetterEx | $BackHebrew_LetterEx);
298
299# rule 10
300
301($BackALetterEx | $BackHebrew_LetterEx) $BackNumericEx;
302
303# rule 11 and 12
304
305$BackNumericEx ($BackMidNumEx | $BackMidNumLetEx | $BackSingle_QuoteEx) $BackNumericEx;
306
307# rule 13
308
309$BackKatakanaEx $BackKatakanaEx;
310
311# rules 13 a/b
312#
313$BackExtendNumLetEx ($BackALetterEx | $BackHebrew_LetterEx | $BackNumericEx | $BackKatakanaEx | $BackExtendNumLetEx);
314($BackALetterEx | $BackHebrew_LetterEx | $BackNumericEx | $BackKatakanaEx) $BackExtendNumLetEx;
315
316# special handling for CJK characters: chain for later dictionary segmentation
317$HangulSyllable $HangulSyllable;
318$KanaKanji $KanaKanji; #different rule status if both kanji and kana found
319
320# rule 14
321
322$E_Modifier ($Format | $Extend | $ZWJ)* ($E_Base | $EBG);
323
324# rule 15 - 17
325# Pairs of Regional Indicators stay together.
326
327^$BackRegional_IndicatorEx / ($BackRegional_IndicatorEx $BackRegional_IndicatorEx)*
328 ($Format | $Extend | $ZWJ)* [[^$Regional_Indicator $Format $Extend $ZWJ] {eof}];
329^$BackRegional_IndicatorEx $BackRegional_IndicatorEx / ($BackRegional_IndicatorEx $BackRegional_IndicatorEx)*
330 ($Format | $Extend | $ZWJ)* [[^$Regional_Indicator $Format $Extend $ZWJ] {eof}];
331
332($Extended_Pict | $EmojiNRK) $ZWJ $BackRegional_IndicatorEx / ($BackRegional_IndicatorEx $BackRegional_IndicatorEx)*
333 ($Format | $Extend | $ZWJ)* [[^$Regional_Indicator $Format $Extend $ZWJ] {eof}];
334($Extended_Pict | $EmojiNRK) $ZWJ $BackRegional_IndicatorEx $BackRegional_IndicatorEx / ($BackRegional_IndicatorEx $BackRegional_IndicatorEx)*
335 ($Format | $Extend | $ZWJ)* [[^$Regional_Indicator $Format $Extend $ZWJ] {eof}];
336
337$Space* {1};
338$Newline* {2};
339
340$Fullstop {20};
341$Dash {21};
342$Single_Quote {22};
343
344(N | n) $Single_Quote (T | t) {202};
345(Y | y) $Single_Quote (A | a) (L | l)* {202};
346
347$Fullstop $Fullstop ($Fullstop*) {40};
348$Dash $Dash ($Dash*) {40};
349$Terminators $Terminators ($Terminators*) {40};
350$Punctuation $Punctuation ($Punctuation*) {40};
351$OtherSingle $OtherSingle ($OtherSingle*) {40};
352
353$Single_Quote $Single_Quote {40};
354$Single_Quote $Single_Quote $Single_Quote* {40};
355
356$Hash ($ALetter | $Numeric)* {30};
357$At ($ALetter | $Numeric)* {31};
358$Dollar $ALetter ($ALetter | $Numeric)* {31};
359
360$Time {50};
361$IPAddress {51};
362
363$ALetter / $IPAddress;
364$ALetter / $Time;
365
366($Colon | $Semicolon) $Parenthesis {32};
367
368## -------------------------------------------------
369
370!!safe_reverse;
371
372# rule 3
373($Extend | $Format | $ZWJ)+ .?;
374
375# rule 6
376($MidLetter | $MidNumLet | $Single_Quote) ($BackALetterEx | $BackHebrew_LetterEx);
377
378# rule 7b
379$Double_Quote $BackHebrew_LetterEx;
380
381
382# rule 11
383($MidNum | $MidNumLet | $Single_Quote) $BackNumericEx;
384
385# rule 13c
386$BackRegional_IndicatorEx*;
387
388# For dictionary-based break
389$dictionary $dictionary;
390
391## -------------------------------------------------
392
393!!safe_forward;
394
395# rule 4
396($Extend | $Format | $ZWJ)+ .?;
397
398# rule 6
399($MidLetterEx | $MidNumLetEx | $Single_QuoteEx) ($ALetterEx | $Hebrew_LetterEx);
400
401# rule 7b
402$Double_QuoteEx $Hebrew_LetterEx;
403
404# rule 11
405($MidNumEx | $MidNumLetEx | $Single_QuoteEx) $NumericEx;
406
407# rule 13c
408$Regional_IndicatorEx*;
409
410# For dictionary-based break
411$dictionary $dictionary;