2 # Copyright (C) 2002-2015, International Business Machines Corporation
3 # and others. All Rights Reserved.
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
11 # Note: Updates to word.txt will usually need to be merged into
12 # word_POSIX.txt also.
14 ##############################################################################
16 # Character class definitions from TR 29
18 ##############################################################################
25 # Character Class Definitions.
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}];
46 $Hiragana = [:Hiragana:];
48 # Special character classes for people & body part emoji:
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];
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.
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];
69 # leave CJK scripts out of ALetterPlus
70 $ALetterPlus = [$ALetter-$dictionaryCJK [$ComplexContext-$Extend-$Control]];
74 # Rules 4 Ignore Format and Extend characters,
75 # except when they appear at the beginning of a region of text.
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)*;
89 $Ideographic = [\p{Ideographic}];
90 $HiraganaEx = $Hiragana ($Extend | $Format)*;
91 $IdeographicEx = $Ideographic ($Extend | $Format)*;
93 ## -------------------------------------------------
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)+;
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}; #
119 # Do not break between most letters.
121 ($ALetterEx | $Hebrew_LetterEx) ($ALetterEx | $Hebrew_LetterEx) {200};
124 ($ALetterEx | $Hebrew_LetterEx) ($MidLetterEx | $MidNumLetEx | $Single_QuoteEx) ($ALetterEx | $Hebrew_LetterEx) {200};
127 $Hebrew_LetterEx $Single_QuoteEx {200};
130 $Hebrew_LetterEx $Double_QuoteEx $Hebrew_LetterEx {200};
134 $NumericEx $NumericEx {100};
138 ($ALetterEx | $Hebrew_LetterEx) $NumericEx {200};
142 $NumericEx ($ALetterEx | $Hebrew_LetterEx) {200};
146 $NumericEx ($MidNumEx | $MidNumLetEx | $Single_QuoteEx) $NumericEx {100};
149 # to be consistent with $KanaKanji $KanaKanhi, changed
151 # See also TestRuleStatus in intltest/rbbiapts.cpp
152 $KatakanaEx $KatakanaEx {400};
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)
162 $ExtendNumLetEx $ALetterEx {200}; # (13b)
163 $ExtendNumLetEx $Hebrew_Letter {200}; # (13b)
164 $ExtendNumLetEx $NumericEx {100}; # (13b)
165 $ExtendNumLetEx $KatakanaEx {400}; # (13b)
169 $RI $RI $Extend* / $RI;
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
175 $EmojiForMods $EmojiVar? $EmojiMods;
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
182 ## -------------------------------------------------
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;
202 ($Format | $Extend)* [^$CR $LF $Newline]?;
206 ($BackALetterEx | $BackHebrew_LetterEx) ($BackALetterEx | $BackHebrew_LetterEx);
210 ($BackALetterEx | $BackHebrew_LetterEx) ($BackMidLetterEx | $BackMidNumLetEx | $BackSingle_QuoteEx) ($BackALetterEx | $BackHebrew_LetterEx);
213 $BackSingle_QuoteEx $BackHebrew_LetterEx;
216 $BackHebrew_LetterEx $BackDouble_QuoteEx $BackHebrew_LetterEx;
220 $BackNumericEx $BackNumericEx;
224 $BackNumericEx ($BackALetterEx | $BackHebrew_LetterEx);
228 ($BackALetterEx | $BackHebrew_LetterEx) $BackNumericEx;
232 $BackNumericEx ($BackMidNumEx | $BackMidNumLetEx | $BackSingle_QuoteEx) $BackNumericEx;
236 $BackKatakanaEx $BackKatakanaEx;
240 $BackExtendNumLetEx ($BackALetterEx | $BackHebrew_LetterEx | $BackNumericEx | $BackKatakanaEx | $BackExtendNumLetEx);
241 ($BackALetterEx | $BackHebrew_LetterEx | $BackNumericEx | $BackKatakanaEx) $BackExtendNumLetEx;
245 $Extend* $RI $RI / $Extend* $RI $RI;
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
251 $EmojiMods $EmojiVar? $EmojiForMods;
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
257 ## -------------------------------------------------
262 ($Extend | $Format)+ .?;
265 ($MidLetter | $MidNumLet | $Single_Quote) ($BackALetterEx | $BackHebrew_LetterEx);
268 $Double_Quote $BackHebrew_LetterEx;
272 ($MidNum | $MidNumLet | $Single_Quote) $BackNumericEx;
275 # For dictionary-based break
276 $dictionary $dictionary;
278 ## -------------------------------------------------
283 ($Extend | $Format)+ .?;
286 ($MidLetterEx | $MidNumLetEx | $Single_QuoteEx) ($ALetterEx | $Hebrew_LetterEx);
289 $Double_QuoteEx $Hebrew_LetterEx;
292 ($MidNumEx | $MidNumLetEx | $Single_QuoteEx) $NumericEx;
295 # For dictionary-based break
296 $dictionary $dictionary;