1# 2# Copyright (C) 2002-2003, International Business Machines Corporation and others. 3# All Rights Reserved. 4# 5# file: dict_word.txt 6# 7# ICU Word Break Rules 8# See Unicode Standard Annex #29. 9# These rules are based on Version 4.0.0, dated 2003-04-17 10# 11 12 13 14#################################################################################### 15# 16# Character class definitions from TR 29 17# 18#################################################################################### 19$Katakana = [[:Script = KATAKANA:] [:name = KATAKANA-HIRAGANA PROLONGED SOUND MARK:] 20 [:name = HALFWIDTH KATAKANA-HIRAGANA PROLONGED SOUND MARK:] 21 [:name = HALFWIDTH KATAKANA VOICED SOUND MARK:] 22 [:name = HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK:]]; 23 24$Ideographic = [:Ideographic:]; 25$Hangul = [:Script = HANGUL:]; 26 27$ALetter = [\u0002 [:Alphabetic:] [:name= COMMERCIAL AT:] [:name= HEBREW PUNCTUATION GERESH:] 28 - $Ideographic 29 - $Katakana 30 - $Hangul 31 - [:Script = Thai:] 32 - [:Script = Lao:] 33 - [:Script = Hiragana:]]; 34 35$MidLetter = [[:name = APOSTROPHE:] [:name = GRAVE ACCENT:] \u0084 [:name = SOFT HYPHEN:] [:name = MIDDLE DOT:] [:name = GREEK TONOS:] [:name= FULL STOP:] 36 [:name = HEBREW PUNCTUATION GERSHAYIM:] [:name = DOUBLE VERTICAL LINE:] [:name = LEFT SINGLE QUOTATION MARK:] 37 [:name = RIGHT SINGLE QUOTATION MARK:] [:name = HYPHENATION POINT:] [:name = PRIME:] ]; 38 39$SufixLetter = [:name= FULL STOP:]; 40 41 42$MidNum = [[:LineBreak = Infix_Numeric:] [:name= COMMERCIAL AT:] \u0084 [:name = GREEK TONOS:] [:name = ARABIC DECIMAL SEPARATOR:] 43 [:name = LEFT SINGLE QUOTATION MARK:] [:name = RIGHT SINGLE QUOTATION MARK:] [:name = SINGLE HIGH-REVERSED-9 QUOTATION MARK:] 44 [:name = PRIME:]]; 45$Numeric = [:LineBreak = Numeric:]; 46 47 48$TheZWSP = \u200b; 49 50# 51# Character Class Definitions. 52# The names are those from TR29. 53# 54$CR = \u000d; 55$LF = \u000a; 56$Control = [[[:Zl:] [:Zp:] [:Cc:] [:Cf:]] - $TheZWSP]; 57$Extend = [[:Grapheme_Extend = TRUE:]]; 58 59 60 61 62#################################################################################### 63# 64# Word Break Rules. Definitions and Rules specific to word break begin Here. 65# 66#################################################################################### 67 68$Format = [[:Cf:] - $TheZWSP]; 69 70 71 72# Rule 3: Treat a grapheme cluster as if it were a single character. 73# Hangul Syllables are easier to deal with here than they are in Grapheme Clusters 74# because we don't need to find the boundaries between adjacent syllables - 75# they won't be word boundaries. 76# 77 78 79# 80# "Extended" definitions. Grapheme Cluster + Format Chars, treated like the base char. 81# 82$ALetterEx = $ALetter $Extend*; 83$NumericEx = $Numeric $Extend*; 84$MidNumEx = $MidNum $Extend*; 85$MidLetterEx = $MidLetter $Extend*; 86$SufixLetterEx= $SufixLetter $Extend*; 87$KatakanaEx = $Katakana $Extend*; 88$IdeographicEx= $Ideographic $Extend*; 89$HangulEx = $Hangul $Extend*; 90$FormatEx = $Format $Extend*; 91 92 93# 94# Numbers. Rules 8, 11, 12 form the TR. 95# 96$NumberSequence = $NumericEx ($FormatEx* $MidNumEx? $FormatEx* $NumericEx)*; 97$NumberSequence {100}; 98 99# 100# Words. Alpha-numerics. Rule 5, 6, 7, 9, 10 101# - must include at least one letter. 102# - may include both letters and numbers. 103# - may include MideLetter, MidNumber punctuation. 104# 105$LetterSequence = $ALetterEx ($FormatEx* $MidLetterEx? $FormatEx* $ALetterEx)*; # rules #6, #7 106($NumberSequence $FormatEx*)? $LetterSequence ($FormatEx* ($NumberSequence | $LetterSequence))* $SufixLetterEx? {200}; 107 108[[:P:][:S:]]*; 109 110# 111# Do not break between Katakana. Rule #13. 112# 113$KatakanaEx ($FormatEx* $KatakanaEx)* {300}; 114[:Hiragana:] $Extend* {300}; 115 116# 117# Ideographic Characters. Stand by themselves as words. 118# Separated from the "Everything Else" rule, below, only so that they 119# can be tagged with a return value. TODO: is this what we want? 120# 121$IdeographicEx ($FormatEx* $IdeographicEx)* {400}; 122$HangulEx ($FormatEx* $HangulEx)* {400}; 123 124# 125# Everything Else, with no tag. 126# Non-Control chars combine with $Extend (combining) chars. 127# Controls are do not. 128# 129[^$Control [:Ideographic:]] $Extend*; 130$CR $LF; 131 132# 133# Reverse Rules. Back up over any of the chars that can group together. 134# (Reverse rules do not need to be exact; they can back up too far, 135# but must back up at least enough, and must stop on a boundary.) 136# 137 138# NonStarters are the set of all characters that can appear at the 2nd - nth position of 139# a word. (They may also be the first.) The reverse rule skips over these, until it 140# reaches something that can only be the start (and probably only) char in a "word". 141# A space or punctuation meets the test. 142# 143$NonStarters = [$Numeric $ALetter $Katakana $Ideographic $Hangul [:P:] [:S:] $MidLetter $MidNum $SufixLetter $Extend $Format]; 144 145#!.*; 146! ($NonStarters* | \n \r) .; 147 148