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.
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 ##############################################################################
22 ### BEGIN CUSTOMIZATION
23 ### This file contains LibreOffice-specific rule customizations.
25 ### To aid future maintainability:
26 ### - The change location should be bracketed by comments of this form.
27 ### - The original rule should be commented out, and the modified rule placed alongside.
28 ### - By doing this, maintainers can more easily compare to an upstream baseline.
33 !!quoted_literals_only;
37 # Character Class Definitions.
42 $CR = [\p{Word_Break = CR}];
43 $LF = [\p{Word_Break = LF}];
44 $Newline = [\p{Word_Break = Newline}];
45 $Extend = [\p{Word_Break = Extend}-$Han];
46 $ZWJ = [\p{Word_Break = ZWJ}];
47 $Regional_Indicator = [\p{Word_Break = Regional_Indicator}];
48 $Format = [\p{Word_Break = Format}];
49 $Katakana = [\p{Word_Break = Katakana}];
50 $Hebrew_Letter = [\p{Word_Break = Hebrew_Letter}];
51 $Single_Quote = [\p{Word_Break = Single_Quote}];
52 $Double_Quote = [\p{Word_Break = Double_Quote}];
53 $MidNum = [\p{Word_Break = MidNum}];
54 $Numeric = [\p{Word_Break = Numeric}];
55 $WSegSpace = [\p{Word_Break = WSegSpace}];
56 $Extended_Pict = [\p{Extended_Pictographic}];
58 ### BEGIN CUSTOMIZATION
59 ### i#13494: For the purposes of editing, standalone punctuation should be treated as a word.
60 ### This change subtracts undesired characters from the above families
61 ### i#56347: BreakIterator patch for Hungarian
62 ### i#56348: Special chars in first pos not handled by spell checking for Hungarian
64 $Symbols_hu = [[:name = PERCENT SIGN:]
65 [:name = PER MILLE SIGN:]
66 [:name = PER TEN THOUSAND SIGN:]
67 [:name = SECTION SIGN:]
68 [:name = DEGREE SIGN:]
70 [:name = HYPHEN-MINUS:]
74 # $ALetter = [\p{Word_Break = ALetter}];
75 $ALetter = [\p{Word_Break = ALetter} $Symbols_hu];
77 # $MidLetter = [\p{Word_Break = MidLetter}];
78 $MidLetter = [\p{Word_Break = MidLetter} $Symbols_hu];
80 # $MidNumLet = [\p{Word_Break = MidNumLet}];
81 $MidNumLet = [\p{Word_Break = MidNumLet}-[:name= FULL STOP:]];
83 # $ExtendNumLet = [\p{Word_Break = ExtendNumLet}];
84 $ExtendNumLet = [\p{Word_Break = ExtendNumLet}-[:name= LOW LINE:]-[:name = NARROW NO-BREAK SPACE:]];
88 $Hiragana = [:Hiragana:];
89 $Ideographic = [\p{Ideographic}];
92 # Dictionary character set, for triggering language-based break engines. Currently
93 # limited to LineBreak=Complex_Context. Note that this set only works in Unicode
94 # 5.0 or later as the definition of Complex_Context was corrected to include all
95 # characters requiring dictionary break.
97 $Control = [\p{Grapheme_Cluster_Break = Control}];
98 $HangulSyllable = [\uac00-\ud7a3];
99 $ComplexContext = [:LineBreak = Complex_Context:];
100 $KanaKanji = [$Han $Hiragana $Katakana];
101 $dictionaryCJK = [$KanaKanji $HangulSyllable];
102 $dictionary = [$ComplexContext $dictionaryCJK];
104 # TODO: check if handling of katakana in dictionary makes rules incorrect/void
106 # leave CJK scripts out of ALetterPlus
107 $ALetterPlus = [$ALetter-$dictionaryCJK [$ComplexContext-$Extend-$Control]];
110 ## -------------------------------------------------
116 # Rule 3c Do not break within emoji zwj sequences.
117 # ZWJ × \p{Extended_Pictographic}. Precedes WB4, so no intervening Extend chars allowed.
121 # Rule 3d - Keep horizontal whitespace together.
123 $WSegSpace $WSegSpace;
125 # Rule 4 - ignore Format and Extend characters, except when they appear at the beginning
126 # of a region of Text.
128 $ExFm = [$Extend $Format $ZWJ];
130 ^$ExFm+; # This rule fires only when there are format or extend characters at the
131 # start of text, or immediately following another boundary. It groups them, in
132 # the event there are more than one.
134 [^$CR $LF $Newline $ExFm] $ExFm*; # This rule rule attaches trailing format/extends to words,
135 # with no special rule status value.
137 $Numeric $ExFm* {100}; # This group of rules also attach trailing format/extends, but
138 $ALetterPlus $ExFm* {200}; # with rule status set based on the word's final base character.
139 $HangulSyllable {200};
140 $Hebrew_Letter $ExFm* {200};
141 $Katakana $ExFm* {400}; # note: these status values override those from rule 5
142 $Hiragana $ExFm* {400}; # by virtue of being numerically larger.
143 $Ideographic $ExFm* {400}; #
147 # Do not break between most letters.
149 ($ALetterPlus | $Hebrew_Letter) $ExFm* ($ALetterPlus | $Hebrew_Letter);
152 ($ALetterPlus | $Hebrew_Letter) $ExFm* ($MidLetter | $MidNumLet | $Single_Quote) $ExFm* ($ALetterPlus | $Hebrew_Letter) {200};
155 $Hebrew_Letter $ExFm* $Single_Quote {200};
158 $Hebrew_Letter $ExFm* $Double_Quote $ExFm* $Hebrew_Letter;
162 $Numeric $ExFm* $Numeric;
166 ($ALetterPlus | $Hebrew_Letter) $ExFm* $Numeric;
170 $Numeric $ExFm* ($ALetterPlus | $Hebrew_Letter);
174 $Numeric $ExFm* ($MidNum | $MidNumLet | $Single_Quote) $ExFm* $Numeric;
177 # to be consistent with $KanaKanji $KanaKanhi, changed
179 # See also TestRuleStatus in intltest/rbbiapts.cpp
180 $Katakana $ExFm* $Katakana {400};
183 # allow to select numbers with narrow no-break spaces as thousand separators
184 $ExtendNumLetNNBSP = [\p{Word_Break = ExtendNumLet}];
186 $ALetterPlus $ExFm* $ExtendNumLet {200}; # (13a)
187 $Hebrew_Letter $ExFm* $ExtendNumLet {200}; # (13a)
188 $Numeric $ExFm* $ExtendNumLetNNBSP {100}; # (13a)
189 $Katakana $ExFm* $ExtendNumLet {400}; # (13a)
190 $ExtendNumLet $ExFm* $ExtendNumLet {200}; # (13a)
192 $ExtendNumLet $ExFm* $ALetterPlus {200}; # (13b)
193 $ExtendNumLet $ExFm* $Hebrew_Letter {200}; # (13b)
194 $ExtendNumLetNNBSP $ExFm* $Numeric {100}; # (13b)
195 $ExtendNumLet $ExFm* $Katakana {400}; # (13b)
198 # Pairs of Regional Indicators stay together.
199 # With incoming rule chaining disabled by ^, this rule will match exactly two of them.
200 # No other rule begins with a Regional_Indicator, so chaining cannot extend the match.
202 ^$Regional_Indicator $ExFm* $Regional_Indicator;
204 # special handling for CJK characters: chain for later dictionary segmentation
205 $HangulSyllable $HangulSyllable {200};
206 $KanaKanji $KanaKanji {400}; # different rule status if both kana and kanji found
208 ### BEGIN CUSTOMIZATION
209 ### i#13494: For the purposes of editing, standalone punctuation should be treated as a word.
210 ### This customization does not replace any rules.
211 [[:P:][:S:]-[:name = FULL STOP:]]*
212 [[:name = FULL STOP:]]*;
213 ### END CUSTOMIZATION
216 # Match a single code point if no other rule applies.