2 # Licensed to the Apache Software Foundation (ASF) under one or more
3 # contributor license agreements. See the NOTICE file distributed with
4 # this work for additional information regarding copyright ownership.
5 # The ASF licenses this file to You under the Apache License, Version 2.0
6 # (the "License"); you may not use this file except in compliance with
7 # the License. You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 # Default RBBI rules, based on UAX#29.
23 # Character Class Definitions.
26 $CR = [\p{Word_Break = CR}];
27 $LF = [\p{Word_Break = LF}];
28 $Newline = [\p{Word_Break = Newline}];
29 $Extend = [\p{Word_Break = Extend}];
30 $Format = [\p{Word_Break = Format}];
31 $Katakana = [\p{Word_Break = Katakana}];
32 $ALetter = [\p{Word_Break = ALetter}];
33 $MidNumLet = [\p{Word_Break = MidNumLet}];
34 $MidLetter = [\p{Word_Break = MidLetter}];
35 $MidNum = [\p{Word_Break = MidNum}];
36 $Numeric = [\p{Word_Break = Numeric}[[:Decomposition_Type=Wide:]&[:General_Category=Decimal_Number:]]];
37 $ExtendNumLet = [\p{Word_Break = ExtendNumLet}];
40 # Dictionary character set, for triggering language-based break engines. Currently
41 # limited to LineBreak=Complex_Context. Note that this set only works in Unicode
42 # 5.0 or later as the definition of Complex_Context was corrected to include all
43 # characters requiring dictionary break.
45 $dictionary = [:LineBreak = Complex_Context:];
46 $Control = [\p{Grapheme_Cluster_Break = Control}];
47 $ALetterPlus = [$ALetter [$dictionary-$Extend-$Control]]; # Note: default ALetter does not
48 # include the dictionary characters.
51 # Rules 4 Ignore Format and Extend characters,
52 # except when they appear at the beginning of a region of text.
54 $KatakanaEx = $Katakana ($Extend | $Format)*;
55 $ALetterEx = $ALetterPlus ($Extend | $Format)*;
56 $MidNumLetEx = $MidNumLet ($Extend | $Format)*;
57 $MidLetterEx = $MidLetter ($Extend | $Format)*;
58 $MidNumEx = $MidNum ($Extend | $Format)*;
59 $NumericEx = $Numeric ($Extend | $Format)*;
60 $ExtendNumLetEx = $ExtendNumLet ($Extend | $Format)*;
62 $Hiragana = [\p{script=Hiragana}];
63 $Ideographic = [\p{Ideographic}];
64 $HiraganaEx = $Hiragana ($Extend | $Format)*;
65 $IdeographicEx = $Ideographic ($Extend | $Format)*;
67 ## -------------------------------------------------
76 # Rule 4 - ignore Format and Extend characters, except when they appear at the beginning
77 # of a region of Text. The rule here comes into play when the start of text
78 # begins with a group of Format chars, or with a "word" consisting of a single
79 # char that is not in any of the listed word break categories followed by
81 [^$CR $LF $Newline]? ($Extend | $Format)+;
85 $KatakanaEx {300}; # note: these status values override those from rule 5
86 $HiraganaEx {300}; # by virtual of being numerically larger.
87 $IdeographicEx {400}; #
91 # Do not break between most letters.
93 $ALetterEx $ALetterEx {200};
96 $ALetterEx ($MidLetterEx | $MidNumLetEx) $ALetterEx {200};
100 $NumericEx $NumericEx {100};
104 $ALetterEx $NumericEx {200};
108 $NumericEx $ALetterEx {200};
112 $NumericEx ($MidNumEx | $MidNumLetEx) $NumericEx {100};
116 $KatakanaEx $KatakanaEx {300};
120 $ALetterEx $ExtendNumLetEx {200}; # (13a)
121 $NumericEx $ExtendNumLetEx {100}; # (13a)
122 $KatakanaEx $ExtendNumLetEx {300}; # (13a)
123 $ExtendNumLetEx $ExtendNumLetEx {200}; # (13a)
125 $ExtendNumLetEx $ALetterEx {200}; # (13b)
126 $ExtendNumLetEx $NumericEx {100}; # (13b)
127 $ExtendNumLetEx $KatakanaEx {300}; # (13b)