]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/data/brkitr/word_POSIX.txt
ICU-551.51.4.tar.gz
[apple/icu.git] / icuSources / data / brkitr / word_POSIX.txt
index dc58f9a2d53f0eee2682368cc8dd1f3f79630300..5050340d17985fdba201ba11347a931004cd45aa 100644 (file)
@@ -1,13 +1,15 @@
 #
-# Copyright (C) 2002-2004, International Business Machines Corporation 
+# Copyright (C) 2002-2015, International Business Machines Corporation 
 # and others. All Rights Reserved.
 #
 # file:  word_POSIX.txt
 #
-# ICU Word Break Rules
+# ICU Word Break Rules, POSIX locale.
 #      See Unicode Standard Annex #29.
-#      These rules are based on Version 4.1 draft, dated 2004-11-11
+#      These rules are based on UAX #29 Revision 22 for Unicode Version 6.3
 #
+# Note:  Updates to word.txt will usually need to be merged into
+#        word_POSIX.txt also.
 
 ##############################################################################
 #
 ##############################################################################
 
 !!chain;
+!!RINoChain;
 
-$Katakana  = [[:Script = KATAKANA:]
-                         [:name = VERTICAL KANA REPEAT MARK:]
-                         [:name = VERTICAL KANA REPEAT WITH VOICED SOUND MARK:]
-                         [:name = VERTICAL KANA REPEAT MARK UPPER HALF:]
-                         [:name = VERTICAL KANA REPEAT WITH VOICED SOUND MARK UPPER HALF:]
-                         [:name = VERTICAL KANA REPEAT MARK LOWER HALF:]
-                         [:name = KATAKANA-HIRAGANA VOICED SOUND MARK:]
-                         [:name = KATAKANA-HIRAGANA SEMI-VOICED SOUND MARK:]
-                         [:name = KATAKANA-HIRAGANA DOUBLE HYPHEN:]
-                         [:name = KATAKANA-HIRAGANA PROLONGED SOUND MARK:]
-                         [:name = HALFWIDTH KATAKANA-HIRAGANA PROLONGED SOUND MARK:]
-                         [:name = HALFWIDTH KATAKANA VOICED SOUND MARK:]
-                         [:name = HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK:]];
-
-
-$ALetter   = [[:Alphabetic:] [:name= HEBREW PUNCTUATION GERESH:]
-                                                  - [:Ideographic:]
-                                                  - $Katakana
-                                                  - [:Script = Hiragana:]
-                                                  - [:Script = Lao:]
-                                                  - [:Grapheme_Extend = TRUE:]];
-                                                  
-$MidLetter = [[:name = APOSTROPHE:] [:name = MIDDLE DOT:]
-                         [:name = HEBREW PUNCTUATION GERSHAYIM:]
-                         [:name = RIGHT SINGLE QUOTATION MARK:]
-                         [:name = HYPHENATION POINT:]];
-
-                       
-$MidNum    = [[:LineBreak = Infix_Numeric:]];
-$Numeric   = [[:Nd:][:name = ARABIC DECIMAL SEPARATOR:][:name = ARABIC THOUSANDS SEPARATOR:]];
-$ExtendNumLet = [[:Connector_Punctuation:] 
-                       - [:name = KATAKANA MIDDLE DOT:]
-                       - [:name = HALFWIDTH KATAKANA MIDDLE DOT:]];
-                       
-                       
 
 #
 #  Character Class Definitions.
-#    The names are those from TR29.
 #
 
-$CR             = \u000d;
-$LF             = \u000a;
-$Extend         = [[:Grapheme_Extend = TRUE:]];
-$Control        = [[:Zl:] [:Zp:] [:Cc:] [:Cf:] - $Extend];
-$Format         = [[:Cf:] - $Extend];
-$Hiragana       = [:Hiragana:];
-$Ideographic    = [:IDEOGRAPHIC:];
-
-$ALetterEx      = $ALetter     $Extend*;
-$NumericEx      = $Numeric     $Extend*;
-$MidNumEx       = $MidNum      $Extend*;
-$MidLetterEx    = $MidLetter   $Extend*;
-$KatakanaEx     = $Katakana    $Extend*;
-$ExtendNumLetEx = $ExtendNumLet $Extend*;
+$CR                 = [\p{Word_Break = CR}];
+$LF                 = [\p{Word_Break = LF}];
+$Newline            = [\p{Word_Break = Newline}];
+$Extend             = [\p{Word_Break = Extend}];
+$RI                 = [\p{Word_Break = Regional_Indicator}];
+$Format             = [\p{Word_Break = Format}];
+$Katakana           = [\p{Word_Break = Katakana}];
+$Hebrew_Letter      = [\p{Word_Break = Hebrew_Letter}];
+$ALetter            = [\p{Word_Break = ALetter}];
+$Single_Quote       = [\p{Word_Break = Single_Quote}];
+$Double_Quote       = [\p{Word_Break = Double_Quote}];
+$MidNumLet          = [\p{Word_Break = MidNumLet} - [.]];
+$MidLetter          = [\p{Word_Break = MidLetter} - [\:]];
+$MidNum             = [\p{Word_Break = MidNum} [.]];
+$Numeric            = [\p{Word_Break = Numeric}];
+$ExtendNumLet       = [\p{Word_Break = ExtendNumLet}];
+
+$Han                = [:Han:];
+$Hiragana           = [:Hiragana:];
+
+# Special character classes for people & body part emoji:
+# Subsets of $Extend:
+$ZWJ = \u200D;
+$EmojiVar = \uFE0F;
+# The following are subsets of \p{Word_Break = Other}
+$EmojiForSeqs = [\u2764 \U0001F441 \U0001F466-\U0001F469 \U0001F48B \U0001F5E8];
+$EmojiForMods = [\u261D \u26F9 \u270A-\u270D \U0001F385 \U0001F3C3-\U0001F3C4 \U0001F3CA-\U0001F3CB \U0001F442-\U0001F443 \U0001F446-\U0001F450 \U0001F466-\U0001F469 \U0001F46E-\U0001F478 \U0001F47C \U0001F481-\U0001F483 \U0001F485-\U0001F487 \U0001F4AA \U0001F575 \U0001F590 \U0001F595 \U0001F596 \U0001F645-\U0001F647 \U0001F64B-\U0001F64F \U0001F6A3 \U0001F6B4-\U0001F6B6 \U0001F6C0 \U0001F918];
+$EmojiMods = [\U0001F3FB-\U0001F3FF];
+
+#   Dictionary character set, for triggering language-based break engines. Currently
+#   limited to LineBreak=Complex_Context. Note that this set only works in Unicode
+#   5.0 or later as the definition of Complex_Context was corrected to include all
+#   characters requiring dictionary break.
+
+$Control        = [\p{Grapheme_Cluster_Break = Control}]; 
+$HangulSyllable = [\uac00-\ud7a3];
+$ComplexContext = [:LineBreak = Complex_Context:];
+$KanaKanji      = [$Han $Hiragana $Katakana];
+$dictionaryCJK  = [$KanaKanji $HangulSyllable];
+$dictionary     = [$ComplexContext $dictionaryCJK];
+
+# leave CJK scripts out of ALetterPlus
+$ALetterPlus  = [$ALetter-$dictionaryCJK [$ComplexContext-$Extend-$Control]];
+
+
+#
+#  Rules 4    Ignore Format and Extend characters, 
+#             except when they appear at the beginning of a region of text.
+#
+# TODO: check if handling of katakana in dictionary makes rules incorrect/void
+$KatakanaEx           = $Katakana           ($Extend |  $Format)*;
+$Hebrew_LetterEx      = $Hebrew_Letter      ($Extend |  $Format)*;
+$ALetterEx            = $ALetterPlus        ($Extend |  $Format)*;
+$Single_QuoteEx       = $Single_Quote       ($Extend |  $Format)*;
+$Double_QuoteEx       = $Double_Quote       ($Extend |  $Format)*;
+$MidNumLetEx          = $MidNumLet          ($Extend |  $Format)*;
+$MidLetterEx          = $MidLetter          ($Extend |  $Format)*;
+$MidNumEx             = $MidNum             ($Extend |  $Format)*;
+$NumericEx            = $Numeric            ($Extend |  $Format)*;
+$ExtendNumLetEx       = $ExtendNumLet       ($Extend |  $Format)*;
+
+$Ideographic    = [\p{Ideographic}];
+$HiraganaEx     = $Hiragana     ($Extend |  $Format)*;
+$IdeographicEx  = $Ideographic  ($Extend |  $Format)*;
 
 ## -------------------------------------------------
 
 !!forward;
 
 
-# Rule 3 - don't break grapheme clusters.
-# see character breaks
-
+# Rule 3 - CR x LF
+#
 $CR $LF;
-#[^$Control] $Extend*;
-#$NumericEx $Extend* {100};
-#$ALetterEx $Extend* {200};
-[^$Control] $Extend+;
+
+# Rule 4 - ignore Format and Extend characters, except when they appear at the beginning
+#          of a region of Text.   The rule here comes into play when the start of text
+#          begins with a group of Format chars, or with a "word" consisting of a single
+#          char that is not in any of the listed word break categories followed by
+#          format char(s), or is not a CJK dictionary character.
+[^$CR $LF $Newline]? ($Extend |  $Format)+;
+
 $NumericEx {100};
 $ALetterEx {200};
-$KatakanaEx {300};
+$HangulSyllable {200};
+$Hebrew_LetterEx{200};
+$KatakanaEx {400};       # note:  these status values override those from rule 5
+$HiraganaEx {400};       #        by virtue of being numerically larger.
+$IdeographicEx {400};    #
 
+#
 # rule 5
-
-$ALetterEx $Format* $ALetterEx {200};
+#    Do not break between most letters.
+#
+($ALetterEx | $Hebrew_LetterEx)  ($ALetterEx | $Hebrew_LetterEx) {200};
 
 # rule 6 and 7
-$ALetterEx $Format* $MidLetterEx  $Format* $ALetterEx {200};
+($ALetterEx | $Hebrew_LetterEx) ($MidLetterEx | $MidNumLetEx | $Single_QuoteEx) ($ALetterEx | $Hebrew_LetterEx) {200};
+
+# rule 7a
+$Hebrew_LetterEx $Single_QuoteEx {200};
+
+# rule 7b and 7c
+$Hebrew_LetterEx $Double_QuoteEx $Hebrew_LetterEx {200};
 
 # rule 8
 
-$NumericEx $Format* $NumericEx {100};
+$NumericEx $NumericEx {100};
 
 # rule 9
 
-$ALetterEx $Format* $NumericEx {200};
+($ALetterEx | $Hebrew_LetterEx) $NumericEx {200};
 
 # rule 10
 
-$NumericEx $Format* $ALetterEx {200};
+$NumericEx ($ALetterEx | $Hebrew_LetterEx) {200};
 
 # rule 11 and 12 
 
-$NumericEx $Format* $MidNumEx $Format* $NumericEx {100};
+$NumericEx ($MidNumEx | $MidNumLetEx | $Single_QuoteEx) $NumericEx {100};
 
 # rule 13
-
-$KatakanaEx  $Format* $KatakanaEx {300};
-$Hiragana    $Extend* {300};
-$Ideographic $Extend* {400};
+# to be consistent with $KanaKanji $KanaKanhi, changed
+# from 300 to 400.
+# See also TestRuleStatus in intltest/rbbiapts.cpp
+$KatakanaEx  $KatakanaEx {400};
 
 # rule 13a/b
 
-$ALetterEx  $Format* $ExtendNumLetEx {200};    #  (13a)
-$NumericEx  $Format* $ExtendNumLetEx {100};    #  (13a)
-$KatakanaEx $Format* $ExtendNumLetEx {300};    #  (13a)
-$ExtendNumLetEx $Format* $ExtendNumLetEx{200}; #  (13a)
+$ALetterEx       $ExtendNumLetEx {200};    #  (13a)
+$Hebrew_LetterEx $ExtendNumLetEx {200};    #  (13a)
+$NumericEx       $ExtendNumLetEx {100};    #  (13a)
+$KatakanaEx      $ExtendNumLetEx {400};    #  (13a)
+$ExtendNumLetEx  $ExtendNumLetEx {200};    #  (13a)
+
+$ExtendNumLetEx  $ALetterEx      {200};    #  (13b)
+$ExtendNumLetEx  $Hebrew_Letter  {200};    #  (13b)
+$ExtendNumLetEx  $NumericEx      {100};    #  (13b)
+$ExtendNumLetEx  $KatakanaEx     {400};    #  (13b)
+
+# rule 13c
+
+$RI $RI $Extend* / $RI;
+$RI $RI $Extend*;
 
-$ExtendNumLetEx $Format* $ALetterEx  {200};    #  (13b)
-$ExtendNumLetEx $Format* $NumericEx  {100};    #  (13b)
-$ExtendNumLetEx $Format* $KatakanaEx {300};    #  (13b)
+# Special forward rules for people & body part emoji:
+# don't break $ZWJ from subsequent $EmojiForSeqs; don't break between relevant emoji and $EmojiMods
+$ZWJ $EmojiForSeqs;
+$EmojiForMods $EmojiVar? $EmojiMods;
+
+# special handling for CJK characters: chain for later dictionary segmentation
+$HangulSyllable $HangulSyllable {200};
+$KanaKanji $KanaKanji {400}; # different rule status if both kana and kanji found 
 
 
 ## -------------------------------------------------
 
 !!reverse;
 
-$BackALetterEx     = $Extend* $ALetter;
-$BackNumericEx     = $Extend* $Numeric;
-$BackMidNumEx      = $Extend* $MidNum;
-$BackMidLetterEx   = $Extend* $MidLetter;
-$BackKatakanaEx    = $Extend* $Katakana;
-$BackExtendNumLetEx= $Extend* $ExtendNumLet;
+$BackHebrew_LetterEx      = ($Format | $Extend)* $Hebrew_Letter;
+$BackALetterEx            = ($Format | $Extend)* $ALetterPlus;
+$BackSingle_QuoteEx       = ($Format | $Extend)* $Single_Quote;
+$BackDouble_QuoteEx       = ($Format | $Extend)* $Double_Quote;
+$BackMidNumLetEx          = ($Format | $Extend)* $MidNumLet;
+$BackNumericEx            = ($Format | $Extend)* $Numeric;
+$BackMidNumEx             = ($Format | $Extend)* $MidNum;
+$BackMidLetterEx          = ($Format | $Extend)* $MidLetter;
+$BackKatakanaEx           = ($Format | $Extend)* $Katakana;
+$BackHiraganaEx           = ($Format | $Extend)* $Hiragana;
+$BackExtendNumLetEx       = ($Format | $Extend)* $ExtendNumLet;
 
+# rule 3
 $LF $CR;
 
-# see character breaks
-
-$Extend* [^$Control];
+# rule 4
+($Format | $Extend)*  [^$CR $LF $Newline]?;
 
 # rule 5
 
-$BackALetterEx $Format* $BackALetterEx;
+($BackALetterEx | $BackHebrew_LetterEx) ($BackALetterEx | $BackHebrew_LetterEx);
 
 # rule 6 and 7
 
-$BackALetterEx $Format* $BackMidLetterEx $Format* $BackALetterEx;
+($BackALetterEx | $BackHebrew_LetterEx) ($BackMidLetterEx | $BackMidNumLetEx | $BackSingle_QuoteEx) ($BackALetterEx | $BackHebrew_LetterEx);
+
+# rule 7a
+$BackSingle_QuoteEx $BackHebrew_LetterEx;
 
+# Rule 7b and 7c
+$BackHebrew_LetterEx $BackDouble_QuoteEx $BackHebrew_LetterEx;
 
 # rule 8
 
-$BackNumericEx $Format* $BackNumericEx;
+$BackNumericEx $BackNumericEx;
 
 # rule 9
 
-$BackNumericEx  $Format* $BackALetterEx;
+$BackNumericEx ($BackALetterEx | $BackHebrew_LetterEx);
 
 # rule 10
 
-$BackALetterEx $Format* $BackNumericEx;
+($BackALetterEx | $BackHebrew_LetterEx) $BackNumericEx;
 
 # rule 11 and 12
 
-$BackNumericEx $Format* $BackMidNumEx $Format* $BackNumericEx;
+$BackNumericEx ($BackMidNumEx | $BackMidNumLetEx | $BackSingle_QuoteEx) $BackNumericEx;
 
 # rule 13
 
-$BackKatakanaEx $Format* $BackKatakanaEx;
+$BackKatakanaEx $BackKatakanaEx;
 
 # rules 13 a/b
 #
-($BackALetterEx | $BackNumericEx | $BackKatakanaEx | $BackExtendNumLetEx) $Format* $BackExtendNumLetEx; 
-$BackExtendNumLetEx $Format* ($BackALetterEx | $BackNumericEx | $BackKatakanaEx);        
+$BackExtendNumLetEx ($BackALetterEx | $BackHebrew_LetterEx | $BackNumericEx | $BackKatakanaEx | $BackExtendNumLetEx);
+($BackALetterEx | $BackHebrew_LetterEx | $BackNumericEx | $BackKatakanaEx) $BackExtendNumLetEx; 
+
+# rule 13c
+
+$Extend* $RI $RI / $Extend* $RI $RI;
+$Extend* $RI $RI;
+
+# Special reverse rules for people & body part emoji:
+# don't break $ZWJ from subsequent $EmojiForSeqs; don't break between relevant emoji and $EmojiMods
+$EmojiForSeqs $ZWJ;
+$EmojiMods $EmojiVar? $EmojiForMods;
+
+# special handling for CJK characters: chain for later dictionary segmentation
+$HangulSyllable $HangulSyllable;
+$KanaKanji $KanaKanji; #different rule status if both kanji and kana found
 
 ## -------------------------------------------------
 
 !!safe_reverse;
 
 # rule 3
-$Extend+ [^$Extend];
-$Extend+;               # comes into play when buffer _begins_ with an $Extend+.
+($Extend | $Format)+ .?;
 
-# rule 4
-$Format+ $BackALetterEx;
-$Format+ $BackNumericEx;
-$Format+ $BackMidLetterEx;
-$Format+ $BackMidNumEx;
-$Format+ $BackKatakanaEx;
-$Format+ $BackExtendNumLetEx;
+# rule 6
+($MidLetter | $MidNumLet | $Single_Quote) ($BackALetterEx | $BackHebrew_LetterEx);
 
+# rule 7b
+$Double_Quote $BackHebrew_LetterEx;
 
-# rule 6
-$MidLetter $Format* $BackALetterEx;
 
 # rule 11
-$MidNum $Format* $BackNumericEx;
+($MidNum | $MidNumLet | $Single_Quote) $BackNumericEx;
+
+$RI $RI+;
+# For dictionary-based break
+$dictionary $dictionary;
 
 ## -------------------------------------------------
 
 !!safe_forward;
 
-# rule 3
-$Extend+;
-
 # rule 4
-$Extend* $Format+ $ALetterEx;
-$Extend* $Format+ $NumericEx;
-$Extend* $Format+ $MidLetterEx;
-$Extend* $Format+ $MidNumEx;
-$Extend* $Format+ $KatakanaEx;
-$Extend* $Format+ $ExtendNumLetEx;
-
-$Extend+ $Format* $ALetterEx;
-$Extend+ $Format* $NumericEx;
-$Extend+ $Format* $MidLetterEx;
-$Extend+ $Format* $MidNumEx;
-$Extend+ $Format* $KatakanaEx;
-$Extend+ $Format* $ExtendNumLetEx;
+($Extend | $Format)+ .?;
 
 # rule 6
-$MidLetterEx $Format* $ALetterEx;
+($MidLetterEx | $MidNumLetEx | $Single_QuoteEx) ($ALetterEx | $Hebrew_LetterEx);
+
+# rule 7b
+$Double_QuoteEx $Hebrew_LetterEx;
 
 # rule 11
-$MidNumEx $Format* $NumericEx;
+($MidNumEx | $MidNumLetEx | $Single_QuoteEx) $NumericEx;
+
+$RI $RI+;
+# For dictionary-based break
+$dictionary $dictionary;