2 ## The following corresponds to source file from CoreLP of 2018-Jan-17:
3 ## CoreNLP/Tagger.subproj/Tagger.subproj/Source/Tagging/Data/word.txt
4 ## and binary files in CoreLP of 2018-Feb-03:
5 ## CoreNLP.framework/Resources/word.dat [for ICU before 60, including ICU 57]
6 ## CoreNLP.framework/Resources/word_icu60.dat
7 ##############################################################################
9 # Copyright (C) 2002-2016, International Business Machines Corporation
10 # and others. All Rights Reserved.
14 # ICU Word Break Rules
15 # See Unicode Standard Annex #29.
16 # These rules are based on UAX #29 Revision 27 for Unicode Version 8.0
17 # with additions from L2/16-011R3 for Emoji sequences.
19 # Note: Updates to word.txt will usually need to be merged into
20 # word_POSIX.txt also.
22 ##############################################################################
24 # Character class definitions from TR 29
26 ##############################################################################
31 # Smart Tokenizer customization
33 $Fullstop = [\u002E\uFE52\uFF0E];
34 $Dash = [\u002D\uFE63\uFF0D];
36 $Terminators = [\u0021\u00A1\u00A1\u01C3\u01C3\u01C3\u203C\u2048\uFE15\uFF01\u003F];
37 $Parenthesis = [\u0028\u005B\u007B\u0029\u005D\u007D];
38 $Punctuation = [\u007E\u003D\u002A\u003C\u003E];
39 $OtherSingle = [\u0060\u0300\u030F];
41 $Hash = [\u0023 \uFE5F \uFF03];
42 $At = [\u0040 \uFE6B \uFF20];
45 $Semicolon = [\u003B];
49 # Character Class Definitions.
52 $E_Base = [\u261D\u26F9\u270A-\u270D\U0001F385\U0001F3C3-\U0001F3C4\U0001F3CA-\U0001F3CB\U0001F442-\U0001F443\U0001F446-\U0001F450\U0001F466-\U0001F469\U0001F46E\U0001F470-\U0001F478\U0001F47C\U0001F481-\U0001F483\U0001F485-\U0001F487\U0001F4AA\U0001F575\U0001F590\U0001F595-\U0001F596\U0001F645-\U0001F647\U0001F64B-\U0001F64F\U0001F6A3\U0001F6B4-\U0001F6B6\U0001F6C0\U0001F918];
53 $E_Modifier = [\U0001F3FB-\U0001F3FF];
55 $GAZ = [\U0001F466-\U0001F469\U0001F48B\U0001F5E8\u2764];
57 $CR = [\p{Word_Break = CR}];
58 $LF = [\p{Word_Break = LF}];
59 $Newline = [\p{Word_Break = Newline} ];
60 $Extend = [[\p{Word_Break = Extend}][:Block=Tags:]];
61 $Regional_Indicator = [\p{Word_Break = Regional_Indicator}];
62 $Format = [[\p{Word_Break = Format}] - [:Block=Tags:]];
63 $Katakana = [\p{Word_Break = Katakana}];
64 $Hebrew_Letter = [\p{Word_Break = Hebrew_Letter}];
65 $ALetter = [\p{Word_Break = ALetter}];
66 $Single_Quote = [\p{Word_Break = Single_Quote}\u2018\u2019];
67 $Double_Quote = [\p{Word_Break = Double_Quote}];
68 $MidNumLet = [\p{Word_Break = MidNumLet}-[$Fullstop $Single_Quote]];
69 $MidLetter = [\p{Word_Break = MidLetter}-[$Single_Quote]];
70 $MidNum = [\p{Word_Break = MidNum}];
71 $Numeric = [\p{Word_Break = Numeric}];
72 $ExtendNumLet = [\p{Word_Break = ExtendNumLet}];
75 $Hiragana = [:Hiragana:];
78 # Dictionary character set, for triggering language-based break engines. Currently
79 # limited to LineBreak=Complex_Context. Note that this set only works in Unicode
80 # 5.0 or later as the definition of Complex_Context was corrected to include all
81 # characters requiring dictionary break.
83 $Control = [\p{Grapheme_Cluster_Break = Control}];
84 $HangulSyllable = [\uac00-\ud7a3];
85 $ComplexContext = [:LineBreak = Complex_Context:];
86 $KanaKanji = [$Han $Hiragana $Katakana];
87 $dictionaryCJK = [$KanaKanji $HangulSyllable];
88 $dictionary = [$ComplexContext $dictionaryCJK];
90 # leave CJK scripts out of ALetterPlus
91 $ALetterPlus = [$ALetter-$dictionaryCJK [$ComplexContext-$Extend-$Control]];
94 # Rules 4 Ignore Format and Extend characters,
95 # except when they appear at the beginning of a region of text.
97 # TODO: check if handling of katakana in dictionary makes rules incorrect/void
98 $KatakanaEx = $Katakana ($Extend | $Format | $ZWJ)*;
99 $Hebrew_LetterEx = $Hebrew_Letter ($Extend | $Format | $ZWJ)*;
100 $ALetterEx = $ALetterPlus ($Extend | $Format | $ZWJ)*;
101 $Single_QuoteEx = $Single_Quote ($Extend | $Format | $ZWJ)*;
102 $Double_QuoteEx = $Double_Quote ($Extend | $Format | $ZWJ)*;
103 $MidNumLetEx = $MidNumLet ($Extend | $Format | $ZWJ)*;
104 $MidLetterEx = $MidLetter ($Extend | $Format | $ZWJ)*;
105 $MidNumEx = $MidNum ($Extend | $Format | $ZWJ)*;
106 $NumericEx = $Numeric ($Extend | $Format | $ZWJ)*;
107 $ExtendNumLetEx = $ExtendNumLet ($Extend | $Format | $ZWJ)*;
108 $Regional_IndicatorEx = $Regional_Indicator ($Extend | $Format | $ZWJ)*;
110 $Ideographic = [\p{Ideographic}];
111 $HiraganaEx = $Hiragana ($Extend | $Format | $ZWJ)*;
112 $IdeographicEx = $Ideographic ($Extend | $Format | $ZWJ)*;
116 $Contraction = (N | n) $Single_Quote (T | t);
117 $Yall = (Y | y) $Single_Quote (A | a) (L | l)*;
119 $Time = (0 | 1 | 2)? $Numeric $Colon (0 | 1 | 2 | 3 | 4 | 5) $Numeric;
120 #$IPAddress = $Numeric? $Numeric? $Numeric $Fullstop $Numeric? $Numeric? $Numeric $Fullstop $Numeric? $Numeric? $Numeric $Fullstop $Numeric? $Numeric? $Numeric;
121 $IPAddress = $Numeric? $Numeric? $Numeric $Fullstop $Numeric? $Numeric? $Numeric;
123 ## -------------------------------------------------
136 $Fullstop $Fullstop ($Fullstop*) {40};
137 $Dash $Dash ($Dash*) {40};
138 $Terminators $Terminators ($Terminators*) {40};
139 $Punctuation $Punctuation ($Punctuation*) {40};
140 $OtherSingle $OtherSingle ($OtherSingle*) {40};
142 $Single_Quote $Single_Quote {40};
143 $Single_Quote $Single_Quote $Single_Quote* {40};
145 $Hash ($ALetter | $Numeric)* {30};
146 $At ($ALetter | $Numeric)* {31};
147 $Dollar $ALetter ($ALetter | $Numeric)* {31};
152 $ALetter / $IPAddress;
155 $IPAddress / $ALetter;
158 ($Colon | $Semicolon) $Parenthesis {32};
160 $Fullstop $Numeric $Numeric;
166 # Rule 3c ZWJ x GAZ. Preceeds WB4, so no intervening Extend chars allowed.
171 # Rule 4 - ignore Format and Extend characters, except when they appear at the beginning
172 # of a region of Text. The rule here comes into play when the start of text
173 # begins with a group of Format chars, or with a "word" consisting of a single
174 # char that is not in any of the listed word break categories followed by
175 # format char(s), or is not a CJK dictionary character.
176 [^$CR $LF $Newline]? ($Extend | $Format | $ZWJ)+;
180 $HangulSyllable {200};
181 $Hebrew_LetterEx{200};
182 $KatakanaEx {400}; # note: these status values override those from rule 5
183 $HiraganaEx {400}; # by virtue of being numerically larger.
184 $IdeographicEx {400}; #
186 $E_Base ($Extend | $Format | $ZWJ)*;
187 $E_Modifier ($Extend | $Format | $ZWJ)*;
188 $GAZ ($Extend | $Format | $ZWJ)*;
192 # Do not break between most letters.
194 ($ALetterEx | $Hebrew_LetterEx) ($ALetterEx | $Hebrew_LetterEx) {200};
197 #($ALetterEx | $Hebrew_LetterEx) ($MidLetterEx | $MidNumLetEx | $Single_QuoteEx) ($ALetterEx | $Hebrew_LetterEx) {200};
198 ($ALetterEx | $Hebrew_LetterEx) ($MidLetterEx | $MidNumLetEx) ($ALetterEx | $Hebrew_LetterEx) {200};
201 #$Hebrew_LetterEx $Single_QuoteEx {200};
204 $Hebrew_LetterEx $Double_QuoteEx $Hebrew_LetterEx {200};
208 $NumericEx $NumericEx {100};
212 ($ALetterEx | $Hebrew_LetterEx) $NumericEx {200};
216 $NumericEx ($ALetterEx | $Hebrew_LetterEx) {200};
220 $NumericEx ($MidNumEx | $MidNumLetEx | $Single_QuoteEx) $NumericEx {100};
223 # to be consistent with $KanaKanji $KanaKanhi, changed
225 # See also TestRuleStatus in intltest/rbbiapts.cpp
226 $KatakanaEx $KatakanaEx {400};
230 $ALetterEx $ExtendNumLetEx {200}; # (13a)
231 $Hebrew_LetterEx $ExtendNumLetEx {200}; # (13a)
232 $NumericEx $ExtendNumLetEx {100}; # (13a)
233 $KatakanaEx $ExtendNumLetEx {400}; # (13a)
234 $ExtendNumLetEx $ExtendNumLetEx {200}; # (13a)
236 $ExtendNumLetEx $ALetterEx {200}; # (13b)
237 $ExtendNumLetEx $Hebrew_Letter {200}; # (13b)
238 $ExtendNumLetEx $NumericEx {100}; # (13b)
239 $ExtendNumLetEx $KatakanaEx {400}; # (13b)
242 # Pairs of Regional Indicators stay together.
243 # With rule chaining disabled by ^, this rule will match exactly two of them.
244 # No other rule begins with a Regional_Indicator, so chaining cannot extend the match.
246 ^$Regional_IndicatorEx $Regional_IndicatorEx;
248 # special handling for CJK characters: chain for later dictionary segmentation
249 $HangulSyllable $HangulSyllable {200};
250 $KanaKanji $KanaKanji {400}; # different rule status if both kana and kanji found
253 # E_Base x E_Modifier
255 ($E_Base | $GAZ) ($Format | $Extend | $ZWJ)* $E_Modifier;
257 ## -------------------------------------------------
261 $BackHebrew_LetterEx = ($Format | $Extend | $ZWJ)* $Hebrew_Letter;
262 $BackALetterEx = ($Format | $Extend | $ZWJ)* $ALetterPlus;
263 $BackSingle_QuoteEx = ($Format | $Extend | $ZWJ)* $Single_Quote;
264 $BackDouble_QuoteEx = ($Format | $Extend | $ZWJ)* $Double_Quote;
265 $BackMidNumLetEx = ($Format | $Extend | $ZWJ)* $MidNumLet;
266 $BackNumericEx = ($Format | $Extend | $ZWJ)* $Numeric;
267 $BackMidNumEx = ($Format | $Extend | $ZWJ)* $MidNum;
268 $BackMidLetterEx = ($Format | $Extend | $ZWJ)* $MidLetter;
269 $BackKatakanaEx = ($Format | $Extend | $ZWJ)* $Katakana;
270 $BackHiraganaEx = ($Format | $Extend | $ZWJ)* $Hiragana;
271 $BackExtendNumLetEx = ($Format | $Extend | $ZWJ)* $ExtendNumLet;
272 $BackRegional_IndicatorEx = ($Format | $Extend | $ZWJ)* $Regional_Indicator;
277 # Rule 3c ZWJ x GAZ. Preceeds WB4, so no intervening Extend chars allowed.
282 ($Format | $Extend | $ZWJ)* [^$CR $LF $Newline]?;
286 ($BackALetterEx | $BackHebrew_LetterEx) ($BackALetterEx | $BackHebrew_LetterEx);
290 #($BackALetterEx | $BackHebrew_LetterEx) ($BackMidLetterEx | $BackMidNumLetEx | $BackSingle_QuoteEx) ($BackALetterEx | $BackHebrew_LetterEx);
291 ($BackALetterEx | $BackHebrew_LetterEx) ($BackMidLetterEx | $BackMidNumLetEx) ($BackALetterEx | $BackHebrew_LetterEx);
294 #$BackSingle_QuoteEx $BackHebrew_LetterEx;
297 $BackHebrew_LetterEx $BackDouble_QuoteEx $BackHebrew_LetterEx;
301 $BackNumericEx $BackNumericEx;
305 $BackNumericEx ($BackALetterEx | $BackHebrew_LetterEx);
309 ($BackALetterEx | $BackHebrew_LetterEx) $BackNumericEx;
313 $BackNumericEx ($BackMidNumEx | $BackMidNumLetEx | $BackSingle_QuoteEx) $BackNumericEx;
317 $BackKatakanaEx $BackKatakanaEx;
321 $BackExtendNumLetEx ($BackALetterEx | $BackHebrew_LetterEx | $BackNumericEx | $BackKatakanaEx | $BackExtendNumLetEx);
322 ($BackALetterEx | $BackHebrew_LetterEx | $BackNumericEx | $BackKatakanaEx) $BackExtendNumLetEx;
326 ^$BackRegional_IndicatorEx / ($BackRegional_IndicatorEx $BackRegional_IndicatorEx)*
327 ($Format | $Extend | $ZWJ)* [[^$Regional_Indicator $Format $Extend $ZWJ] {eof}];
328 ^$BackRegional_IndicatorEx $BackRegional_IndicatorEx / ($BackRegional_IndicatorEx $BackRegional_IndicatorEx)*
329 ($Format | $Extend | $ZWJ)* [[^$Regional_Indicator $Format $Extend $ZWJ] {eof}];
331 $GAZ $ZWJ $BackRegional_IndicatorEx / ($BackRegional_IndicatorEx $BackRegional_IndicatorEx)*
332 ($Format | $Extend | $ZWJ)* [[^$Regional_Indicator $Format $Extend $ZWJ] {eof}];
333 $GAZ $ZWJ $BackRegional_IndicatorEx $BackRegional_IndicatorEx / ($BackRegional_IndicatorEx $BackRegional_IndicatorEx)*
334 ($Format | $Extend | $ZWJ)* [[^$Regional_Indicator $Format $Extend $ZWJ] {eof}];
336 # special handling for CJK characters: chain for later dictionary segmentation
337 $HangulSyllable $HangulSyllable;
338 $KanaKanji $KanaKanji; #different rule status if both kanji and kana found
342 $E_Modifier ($Format | $Extend | $ZWJ)* ($E_Base | $GAZ);
346 ## -------------------------------------------------
352 ($Extend | $Format | $ZWJ)+ .?;
355 #($MidLetter | $MidNumLet | $Single_Quote) ($BackALetterEx | $BackHebrew_LetterEx);
356 ($MidLetter | $MidNumLet) ($BackALetterEx | $BackHebrew_LetterEx);
359 $Double_Quote $BackHebrew_LetterEx;
363 #($MidNum | $MidNumLet | $Single_Quote) $BackNumericEx;
364 ($MidNum | $MidNumLet) $BackNumericEx;
367 $BackRegional_IndicatorEx*;
369 # For dictionary-based break
370 $dictionary $dictionary;
372 ## -------------------------------------------------
378 ($Extend | $Format | $ZWJ)+ .?;
381 #($MidLetterEx | $MidNumLetEx | $Single_QuoteEx) ($ALetterEx | $Hebrew_LetterEx);
382 ($MidLetterEx | $MidNumLetEx) ($ALetterEx | $Hebrew_LetterEx);
385 $Double_QuoteEx $Hebrew_LetterEx;
388 #($MidNumEx | $MidNumLetEx | $Single_QuoteEx) $NumericEx;
389 ($MidNumEx | $MidNumLetEx) $NumericEx;
392 $Regional_IndicatorEx*;
394 # For dictionary-based break
395 $dictionary $dictionary;