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 $ALetter = [\p{Word_Break = ALetter}];
52 $Single_Quote = [\p{Word_Break = Single_Quote}];
53 $MidNumLet = [\p{Word_Break = MidNumLet}];
54 $MidNum = [\p{Word_Break = MidNum}];
55 $Numeric = [\p{Word_Break = Numeric}];
56 $ExtendNumLet = [\p{Word_Break = ExtendNumLet}-[:name = NARROW NO-BREAK SPACE:]];
57 $WSegSpace = [\p{Word_Break = WSegSpace}];
58 $Extended_Pict = [\p{Extended_Pictographic}];
60 ### BEGIN CUSTOMIZATION
61 ### Unknown issue number: Dictionary words can contain hyphens
62 ### tdf#49885: Sync custom BreakIterator rules with ICU originals
63 ### - ICU is now more permissive about punctuation inside words.
64 ### - For compatibility, exclude certain characters that were previously excluded.
66 $IncludedML = [:name = HYPHEN-MINUS:];
67 $ExcludedML = [[:name = COLON:]
68 [:name = GREEK ANO TELEIA:]
69 [:name = PRESENTATION FORM FOR VERTICAL COLON:]
70 [:name = SMALL COLON:]
71 [:name = FULLWIDTH COLON:]];
73 ### tdf#162514: For spell checking, abbreviations may end with a period.
74 $PostPeriod = [:name = FULL STOP:];
76 # $MidLetter = [\p{Word_Break = MidLetter}];
77 $MidLetter = [[\p{Word_Break = MidLetter}]-$ExcludedML $IncludedML];
79 ### tdf#46950: Right double-quotes are also used as substitutes for Hebrew gershaim
80 # $Double_Quote = [\p{Word_Break = Double_Quote}];
81 $Double_Quote = [[\p{Word_Break = Double_Quote}][:name= RIGHT DOUBLE QUOTATION MARK:]];
85 $Hiragana = [:Hiragana:];
86 $Ideographic = [\p{Ideographic}];
89 # Dictionary character set, for triggering language-based break engines. Currently
90 # limited to LineBreak=Complex_Context. Note that this set only works in Unicode
91 # 5.0 or later as the definition of Complex_Context was corrected to include all
92 # characters requiring dictionary break.
94 $Control = [\p{Grapheme_Cluster_Break = Control}];
95 $HangulSyllable = [\uac00-\ud7a3];
96 $ComplexContext = [:LineBreak = Complex_Context:];
97 $KanaKanji = [$Han $Hiragana $Katakana];
98 $dictionaryCJK = [$KanaKanji $HangulSyllable];
99 $dictionary = [$ComplexContext $dictionaryCJK];
101 # TODO: check if handling of katakana in dictionary makes rules incorrect/void
103 # leave CJK scripts out of ALetterPlus
104 $ALetterPlus = [$ALetter-$dictionaryCJK [$ComplexContext-$Extend-$Control]];
107 ## -------------------------------------------------
113 # Rule 3c Do not break within emoji zwj sequences.
114 # ZWJ × \p{Extended_Pictographic}. Precedes WB4, so no intervening Extend chars allowed.
118 # Rule 3d - Keep horizontal whitespace together.
120 $WSegSpace $WSegSpace;
122 # Rule 4 - ignore Format and Extend characters, except when they appear at the beginning
123 # of a region of Text.
125 $ExFm = [$Extend $Format $ZWJ];
127 ^$ExFm+; # This rule fires only when there are format or extend characters at the
128 # start of text, or immediately following another boundary. It groups them, in
129 # the event there are more than one.
131 [^$CR $LF $Newline $ExFm] $ExFm*; # This rule rule attaches trailing format/extends to words,
132 # with no special rule status value.
134 $Numeric $ExFm* {100}; # This group of rules also attach trailing format/extends, but
135 $ALetterPlus $ExFm* {200}; # with rule status set based on the word's final base character.
136 $HangulSyllable {200};
137 $Hebrew_Letter $ExFm* {200};
138 $Katakana $ExFm* {400}; # note: these status values override those from rule 5
139 $Hiragana $ExFm* {400}; # by virtue of being numerically larger.
140 $Ideographic $ExFm* {400}; #
144 # Do not break between most letters.
147 ### BEGIN CUSTOMIZATION
148 ### tdf#162514: For spell checking, abbreviations may end with a period.
150 # ($ALetterPlus | $Hebrew_Letter) $ExFm* ($ALetterPlus | $Hebrew_Letter);
151 ($ALetterPlus | $Hebrew_Letter) $ExFm* ($ALetterPlus | $Hebrew_Letter) ($PostPeriod)?;
153 ### END CUSTOMIZATION
157 ### BEGIN CUSTOMIZATION
158 ### tdf#162514: For spell checking, abbreviations may end with a period.
160 # ($ALetterPlus | $Hebrew_Letter) $ExFm* ($MidLetter | $MidNumLet | $Single_Quote) $ExFm* ($ALetterPlus | $Hebrew_Letter) {200};
161 ($ALetterPlus | $Hebrew_Letter) $ExFm* ($MidLetter | $MidNumLet | $Single_Quote) $ExFm* ($ALetterPlus | $Hebrew_Letter) ($PostPeriod)? {200};
163 ### END CUSTOMIZATION
166 $Hebrew_Letter $ExFm* $Single_Quote {200};
169 $Hebrew_Letter $ExFm* $Double_Quote $ExFm* $Hebrew_Letter;
173 $Numeric $ExFm* $Numeric;
177 ($ALetterPlus | $Hebrew_Letter) $ExFm* $Numeric;
181 $Numeric $ExFm* ($ALetterPlus | $Hebrew_Letter);
185 $Numeric $ExFm* ($MidNum | $MidNumLet | $Single_Quote) $ExFm* $Numeric;
188 # to be consistent with $KanaKanji $KanaKanhi, changed
190 # See also TestRuleStatus in intltest/rbbiapts.cpp
191 $Katakana $ExFm* $Katakana {400};
195 $ALetterPlus $ExFm* $ExtendNumLet {200}; # (13a)
196 $Hebrew_Letter $ExFm* $ExtendNumLet {200}; # (13a)
197 $Numeric $ExFm* $ExtendNumLet {100}; # (13a)
198 $Katakana $ExFm* $ExtendNumLet {400}; # (13a)
199 $ExtendNumLet $ExFm* $ExtendNumLet {200}; # (13a)
201 $ExtendNumLet $ExFm* $ALetterPlus {200}; # (13b)
202 $ExtendNumLet $ExFm* $Hebrew_Letter {200}; # (13b)
203 $ExtendNumLet $ExFm* $Numeric {100}; # (13b)
204 $ExtendNumLet $ExFm* $Katakana {400}; # (13b)
207 # Pairs of Regional Indicators stay together.
208 # With incoming rule chaining disabled by ^, this rule will match exactly two of them.
209 # No other rule begins with a Regional_Indicator, so chaining cannot extend the match.
211 ^$Regional_Indicator $ExFm* $Regional_Indicator;
213 # special handling for CJK characters: chain for later dictionary segmentation
214 $HangulSyllable $HangulSyllable {200};
215 $KanaKanji $KanaKanji {400}; # different rule status if both kana and kanji found
218 # Match a single code point if no other rule applies.