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.
9 # ICU Word Break Rules, fi/sv locales (these are actually the standard UAX #29 rules)
10 # See Unicode Standard Annex #29.
11 # These rules are based on UAX #29 Revision 34 for Unicode Version 12.0
13 # Note: Updates to word.txt will usually need to be merged into
14 # word_POSIX.txt also.
16 ##############################################################################
18 # Character class definitions from TR 29
20 ##############################################################################
23 !!quoted_literals_only;
27 # Character Class Definitions.
30 $CR = [\p{Word_Break = CR}];
31 $LF = [\p{Word_Break = LF}];
32 $Newline = [\p{Word_Break = Newline} ];
33 $Extend = [\p{Word_Break = Extend}];
34 $ZWJ = [\p{Word_Break = ZWJ}];
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}] [\uFF10-\uff19]]; # Patch for ICU-12079
46 $ExtendNumLet = [\p{Word_Break = ExtendNumLet}];
47 $WSegSpace = [\p{Word_Break = WSegSpace}];
48 $Extended_Pict = [:ExtPict:];
51 $Hiragana = [:Hiragana:];
54 # Dictionary character set, for triggering language-based break engines. Currently
55 # limited to LineBreak=Complex_Context. Note that this set only works in Unicode
56 # 5.0 or later as the definition of Complex_Context was corrected to include all
57 # characters requiring dictionary break.
59 $Control = [\p{Grapheme_Cluster_Break = Control}];
60 $HangulSyllable = [\uac00-\ud7a3];
61 $ComplexContext = [:LineBreak = Complex_Context:];
62 $KanaKanji = [$Han $Hiragana $Katakana];
63 $dictionaryCJK = [$KanaKanji $HangulSyllable];
64 $dictionary = [$ComplexContext $dictionaryCJK];
66 # leave CJK scripts out of ALetterPlus
67 $ALetterPlus = [$ALetter-$dictionaryCJK [$ComplexContext-$Extend-$Control]];
71 # Rules 4 Ignore Format and Extend characters,
72 # except when they appear at the beginning of a region of text.
74 # TODO: check if handling of katakana in dictionary makes rules incorrect/void
75 $KatakanaEx = $Katakana ($Extend | $Format | $ZWJ)*;
76 $Hebrew_LetterEx = $Hebrew_Letter ($Extend | $Format | $ZWJ)*;
77 $ALetterEx = $ALetterPlus ($Extend | $Format | $ZWJ)*;
78 $Single_QuoteEx = $Single_Quote ($Extend | $Format | $ZWJ)*;
79 $Double_QuoteEx = $Double_Quote ($Extend | $Format | $ZWJ)*;
80 $MidNumLetEx = $MidNumLet ($Extend | $Format | $ZWJ)*;
81 $MidLetterEx = $MidLetter ($Extend | $Format | $ZWJ)*;
82 $MidNumEx = $MidNum ($Extend | $Format | $ZWJ)*;
83 $NumericEx = $Numeric ($Extend | $Format | $ZWJ)*;
84 $ExtendNumLetEx = $ExtendNumLet ($Extend | $Format | $ZWJ)*;
85 $Regional_IndicatorEx = $Regional_Indicator ($Extend | $Format | $ZWJ)*;
87 $Ideographic = [\p{Ideographic}];
88 $HiraganaEx = $Hiragana ($Extend | $Format | $ZWJ)*;
89 $IdeographicEx = $Ideographic ($Extend | $Format | $ZWJ)*;
91 ## -------------------------------------------------
97 # Rule 3c ZWJ x (Extended_Pict | EmojiNRK). Precedes WB4, so no intervening Extend chars allowed.
101 # Rule 3d - Keep horizontal whitespace together.
103 $WSegSpace $WSegSpace;
105 # Rule 4 - ignore Format and Extend characters, except when they appear at the beginning
106 # of a region of Text. The rule here comes into play when the start of text
107 # begins with a group of Format chars, or with a "word" consisting of a single
108 # char that is not in any of the listed word break categories followed by
109 # format char(s), or is not a CJK dictionary character.
110 [^$CR $LF $Newline]? ($Extend | $Format | $ZWJ)+;
114 $HangulSyllable {200};
115 $Hebrew_LetterEx{200};
116 $KatakanaEx {400}; # note: these status values override those from rule 5
117 $HiraganaEx {400}; # by virtue of being numerically larger.
118 $IdeographicEx {400}; #
120 $Extended_Pict ($Extend | $Format | $ZWJ)*;
124 # Do not break between most letters.
126 ($ALetterEx | $Hebrew_LetterEx) ($ALetterEx | $Hebrew_LetterEx) {200};
129 ($ALetterEx | $Hebrew_LetterEx) ($MidLetterEx | $MidNumLetEx | $Single_QuoteEx) ($ALetterEx | $Hebrew_LetterEx) {200};
132 $Hebrew_LetterEx $Single_QuoteEx {200};
135 $Hebrew_LetterEx $Double_QuoteEx $Hebrew_LetterEx {200};
139 $NumericEx $NumericEx {100};
143 ($ALetterEx | $Hebrew_LetterEx) $NumericEx {200};
147 $NumericEx ($ALetterEx | $Hebrew_LetterEx) {200};
151 $NumericEx ($MidNumEx | $MidNumLetEx | $Single_QuoteEx) $NumericEx {100};
154 # to be consistent with $KanaKanji $KanaKanhi, changed
156 # See also TestRuleStatus in intltest/rbbiapts.cpp
157 $KatakanaEx $KatakanaEx {400};
161 $ALetterEx $ExtendNumLetEx {200}; # (13a)
162 $Hebrew_LetterEx $ExtendNumLetEx {200}; # (13a)
163 $NumericEx $ExtendNumLetEx {100}; # (13a)
164 $KatakanaEx $ExtendNumLetEx {400}; # (13a)
165 $ExtendNumLetEx $ExtendNumLetEx {200}; # (13a)
167 $ExtendNumLetEx $ALetterEx {200}; # (13b)
168 $ExtendNumLetEx $Hebrew_Letter {200}; # (13b)
169 $ExtendNumLetEx $NumericEx {100}; # (13b)
170 $ExtendNumLetEx $KatakanaEx {400}; # (13b)
173 # Pairs of Regional Indicators stay together.
174 # With rule chaining disabled by ^, this rule will match exactly two of them.
175 # No other rule begins with a Regional_Indicator, so chaining cannot extend the match.
177 ^$Regional_IndicatorEx $Regional_IndicatorEx;
179 # special handling for CJK characters: chain for later dictionary segmentation
180 $HangulSyllable $HangulSyllable {200};
181 $KanaKanji $KanaKanji {400}; # different rule status if both kana and kanji found
184 # Match a single code point if no other rule applies.