2 ## The following corresponds to source file from CoreLP of 2018-Jan-17:
3 ## CoreNLP/Tagger.subproj/Source/Data/word.txt
4 ##############################################################################
6 # Copyright (C) 2002-2013, International Business Machines Corporation
7 # and others. All Rights Reserved.
11 # ICU Word Break Rules
12 # See Unicode Standard Annex #29.
13 # These rules are based on UAX #29 Revision 22 for Unicode Version 6.3
15 # Note: Updates to word.txt will usually need to be merged into
16 # word_POSIX.txt also.
18 ##############################################################################
20 # Character class definitions from TR 29
22 ##############################################################################
28 # Character Class Definitions.
31 $CR = [\p{Word_Break = CR}];
32 $LF = [\p{Word_Break = LF}];
33 $Newline = [\p{Word_Break = Newline}];
34 $Extend = [\p{Word_Break = Extend}];
35 $Regional_Indicator = [\p{Word_Break = Regional_Indicator}];
36 $Format = [\p{Word_Break = Format}];
37 $Katakana = [\p{Word_Break = Katakana}];
38 $Hebrew_Letter = [\p{Word_Break = Hebrew_Letter}];
39 $ALetter = [\p{Word_Break = ALetter}];
40 $Single_Quote = [\p{Word_Break = Single_Quote}];
41 $Double_Quote = [\p{Word_Break = Double_Quote}];
42 $MidNumLet = [\p{Word_Break = MidNumLet}];
43 $MidLetter = [\p{Word_Break = MidLetter}];
44 $MidNum = [\p{Word_Break = MidNum}];
45 $Numeric = [\p{Word_Break = Numeric}];
46 $ExtendNumLet = [\p{Word_Break = ExtendNumLet}];
49 $Hiragana = [:Hiragana:];
52 # Dictionary character set, for triggering language-based break engines. Currently
53 # limited to LineBreak=Complex_Context. Note that this set only works in Unicode
54 # 5.0 or later as the definition of Complex_Context was corrected to include all
55 # characters requiring dictionary break.
57 $Control = [\p{Grapheme_Cluster_Break = Control}];
58 $HangulSyllable = [\uac00-\ud7a3];
59 $ComplexContext = [:LineBreak = Complex_Context:];
60 $KanaKanji = [$Han $Hiragana $Katakana];
61 $dictionaryCJK = [$KanaKanji $HangulSyllable];
62 $dictionary = [$ComplexContext $dictionaryCJK];
64 # leave CJK scripts out of ALetterPlus
65 $ALetterPlus = [$ALetter-$dictionaryCJK [$ComplexContext-$Extend-$Control]];
69 # Rules 4 Ignore Format and Extend characters,
70 # except when they appear at the beginning of a region of text.
72 # TODO: check if handling of katakana in dictionary makes rules incorrect/void
73 $KatakanaEx = $Katakana ($Extend | $Format)*;
74 $Hebrew_LetterEx = $Hebrew_Letter ($Extend | $Format)*;
75 $ALetterEx = $ALetterPlus ($Extend | $Format)*;
76 $Single_QuoteEx = $Single_Quote ($Extend | $Format)*;
77 $Double_QuoteEx = $Double_Quote ($Extend | $Format)*;
78 $MidNumLetEx = $MidNumLet ($Extend | $Format)*;
79 $MidLetterEx = $MidLetter ($Extend | $Format)*;
80 $MidNumEx = $MidNum ($Extend | $Format)*;
81 $NumericEx = $Numeric ($Extend | $Format)*;
82 $ExtendNumLetEx = $ExtendNumLet ($Extend | $Format)*;
83 $Regional_IndicatorEx = $Regional_Indicator ($Extend | $Format)*;
85 $Ideographic = [\p{Ideographic}];
86 $HiraganaEx = $Hiragana ($Extend | $Format)*;
87 $IdeographicEx = $Ideographic ($Extend | $Format)*;
89 ## -------------------------------------------------
98 # Rule 4 - ignore Format and Extend characters, except when they appear at the beginning
99 # of a region of Text. The rule here comes into play when the start of text
100 # begins with a group of Format chars, or with a "word" consisting of a single
101 # char that is not in any of the listed word break categories followed by
102 # format char(s), or is not a CJK dictionary character.
103 [^$CR $LF $Newline]? ($Extend | $Format)+;
107 $HangulSyllable {200};
108 $Hebrew_LetterEx{200};
109 $KatakanaEx {400}; # note: these status values override those from rule 5
110 $HiraganaEx {400}; # by virtue of being numerically larger.
111 $IdeographicEx {400}; #
115 # Do not break between most letters.
117 ($ALetterEx | $Hebrew_LetterEx) ($ALetterEx | $Hebrew_LetterEx) {200};
120 ($ALetterEx | $Hebrew_LetterEx) ($MidLetterEx | $MidNumLetEx | $Single_QuoteEx) ($ALetterEx | $Hebrew_LetterEx) {200};
123 $Hebrew_LetterEx $Single_QuoteEx {200};
126 $Hebrew_LetterEx $Double_QuoteEx $Hebrew_LetterEx {200};
130 $NumericEx $NumericEx {100};
134 ($ALetterEx | $Hebrew_LetterEx) $NumericEx {200};
138 $NumericEx ($ALetterEx | $Hebrew_LetterEx) {200};
142 $NumericEx ($MidNumEx | $MidNumLetEx | $Single_QuoteEx) $NumericEx {100};
145 # to be consistent with $KanaKanji $KanaKanhi, changed
147 # See also TestRuleStatus in intltest/rbbiapts.cpp
148 $KatakanaEx $KatakanaEx {400};
152 $ALetterEx $ExtendNumLetEx {200}; # (13a)
153 $Hebrew_LetterEx $ExtendNumLetEx {200}; # (13a)
154 $NumericEx $ExtendNumLetEx {100}; # (13a)
155 $KatakanaEx $ExtendNumLetEx {400}; # (13a)
156 $ExtendNumLetEx $ExtendNumLetEx {200}; # (13a)
158 $ExtendNumLetEx $ALetterEx {200}; # (13b)
159 $ExtendNumLetEx $Hebrew_Letter {200}; # (13b)
160 $ExtendNumLetEx $NumericEx {100}; # (13b)
161 $ExtendNumLetEx $KatakanaEx {400}; # (13b)
165 $Regional_IndicatorEx $Regional_IndicatorEx;
167 # special handling for CJK characters: chain for later dictionary segmentation
168 $HangulSyllable $HangulSyllable {200};
169 $KanaKanji $KanaKanji {400}; # different rule status if both kana and kanji found
172 ## -------------------------------------------------
176 $BackHebrew_LetterEx = ($Format | $Extend)* $Hebrew_Letter;
177 $BackALetterEx = ($Format | $Extend)* $ALetterPlus;
178 $BackSingle_QuoteEx = ($Format | $Extend)* $Single_Quote;
179 $BackDouble_QuoteEx = ($Format | $Extend)* $Double_Quote;
180 $BackMidNumLetEx = ($Format | $Extend)* $MidNumLet;
181 $BackNumericEx = ($Format | $Extend)* $Numeric;
182 $BackMidNumEx = ($Format | $Extend)* $MidNum;
183 $BackMidLetterEx = ($Format | $Extend)* $MidLetter;
184 $BackKatakanaEx = ($Format | $Extend)* $Katakana;
185 $BackHiraganaEx = ($Format | $Extend)* $Hiragana;
186 $BackExtendNumLetEx = ($Format | $Extend)* $ExtendNumLet;
187 $BackRegional_IndicatorEx = ($Format | $Extend)* $Regional_Indicator;
193 ($Format | $Extend)* [^$CR $LF $Newline]?;
197 ($BackALetterEx | $BackHebrew_LetterEx) ($BackALetterEx | $BackHebrew_LetterEx);
201 ($BackALetterEx | $BackHebrew_LetterEx) ($BackMidLetterEx | $BackMidNumLetEx | $BackSingle_QuoteEx) ($BackALetterEx | $BackHebrew_LetterEx);
204 $BackSingle_QuoteEx $BackHebrew_LetterEx;
207 $BackHebrew_LetterEx $BackDouble_QuoteEx $BackHebrew_LetterEx;
211 $BackNumericEx $BackNumericEx;
215 $BackNumericEx ($BackALetterEx | $BackHebrew_LetterEx);
219 ($BackALetterEx | $BackHebrew_LetterEx) $BackNumericEx;
223 $BackNumericEx ($BackMidNumEx | $BackMidNumLetEx | $BackSingle_QuoteEx) $BackNumericEx;
227 $BackKatakanaEx $BackKatakanaEx;
231 $BackExtendNumLetEx ($BackALetterEx | $BackHebrew_LetterEx | $BackNumericEx | $BackKatakanaEx | $BackExtendNumLetEx);
232 ($BackALetterEx | $BackHebrew_LetterEx | $BackNumericEx | $BackKatakanaEx) $BackExtendNumLetEx;
236 $BackRegional_IndicatorEx $BackRegional_IndicatorEx;
238 # special handling for CJK characters: chain for later dictionary segmentation
239 $HangulSyllable $HangulSyllable;
240 $KanaKanji $KanaKanji; #different rule status if both kanji and kana found
242 ## -------------------------------------------------
247 ($Extend | $Format)+ .?;
250 ($MidLetter | $MidNumLet | $Single_Quote) ($BackALetterEx | $BackHebrew_LetterEx);
253 $Double_Quote $BackHebrew_LetterEx;
257 ($MidNum | $MidNumLet | $Single_Quote) $BackNumericEx;
259 # For dictionary-based break
260 $dictionary $dictionary;
262 ## -------------------------------------------------
267 ($Extend | $Format)+ .?;
270 ($MidLetterEx | $MidNumLetEx | $Single_QuoteEx) ($ALetterEx | $Hebrew_LetterEx);
273 $Double_QuoteEx $Hebrew_LetterEx;
276 ($MidNumEx | $MidNumLetEx | $Single_QuoteEx) $NumericEx;
278 # For dictionary-based break
279 $dictionary $dictionary;