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 [:name = PERCENT SIGN:] [:name = PER MILLE SIGN:] [:name = PER TEN THOUSAND SIGN:] 29 [:name = SECTION SIGN:] [:name = DEGREE SIGN:] [:name = EURO SIGN:] 30 [:name = HYPHEN-MINUS:] [:name = EN DASH:] [:name = EM DASH:] 31 [:name = DIGIT ZERO:] 32 [:name = DIGIT ONE:] 33 [:name = DIGIT TWO:] 34 [:name = DIGIT THREE:] 35 [:name = DIGIT FOUR:] 36 [:name = DIGIT FIVE:] 37 [:name = DIGIT SIX:] 38 [:name = DIGIT SEVEN:] 39 [:name = DIGIT EIGHT:] 40 [:name = DIGIT NINE:] 41 - $Ideographic 42 - $Katakana 43 - $Hangul 44 - [:Script = Thai:] 45 - [:Script = Lao:] 46 - [:Script = Hiragana:]]; 47 48$MidLetter = [[:name = APOSTROPHE:] [:name = GRAVE ACCENT:] \u0084 [:name = SOFT HYPHEN:] [:name = MIDDLE DOT:] [:name = GREEK TONOS:] 49 [:name = HEBREW PUNCTUATION GERSHAYIM:] [:name = DOUBLE VERTICAL LINE:] [:name = LEFT SINGLE QUOTATION MARK:] 50 [:name = RIGHT SINGLE QUOTATION MARK:] [:name = HYPHENATION POINT:] [:name = PRIME:] [:name = HYPHEN-MINUS:] 51 [:name = EURO SIGN:] [:name = PERCENT SIGN:] [:name = PER MILLE SIGN:] [:name = PER TEN THOUSAND SIGN:] 52 [:name = EN DASH:] [:name = EM DASH:] 53 [:name = FULL STOP:] [:name = PERCENT SIGN:] [:name = SECTION SIGN:] [:name = DEGREE SIGN:]]; 54 55$SufixLetter = [:name= FULL STOP:]; 56 57$MidNum = [[:LineBreak = Infix_Numeric:] [:name= COMMERCIAL AT:] \u0084 [:name = GREEK TONOS:] [:name = ARABIC DECIMAL SEPARATOR:] 58 [:name = LEFT SINGLE QUOTATION MARK:] [:name = RIGHT SINGLE QUOTATION MARK:] [:name = SINGLE HIGH-REVERSED-9 QUOTATION MARK:] 59 [:name = PRIME:]]; 60$Numeric = [:LineBreak = Numeric:]; 61 62 63$TheZWSP = \u200b; 64 65# 66# Character Class Definitions. 67# The names are those from TR29. 68# 69$CR = \u000d; 70$LF = \u000a; 71$Control = [[[:Zl:] [:Zp:] [:Cc:] [:Cf:]] - $TheZWSP]; 72$Extend = [[:Grapheme_Extend = TRUE:]]; 73 74 75 76 77#################################################################################### 78# 79# Word Break Rules. Definitions and Rules specific to word break begin Here. 80# 81#################################################################################### 82 83$Format = [[:Cf:] - $TheZWSP]; 84 85 86 87# Rule 3: Treat a grapheme cluster as if it were a single character. 88# Hangul Syllables are easier to deal with here than they are in Grapheme Clusters 89# because we don't need to find the boundaries between adjacent syllables - 90# they won't be word boundaries. 91# 92 93 94# 95# "Extended" definitions. Grapheme Cluster + Format Chars, treated like the base char. 96# 97$ALetterEx = $ALetter $Extend*; 98$NumericEx = $Numeric $Extend*; 99$MidNumEx = $MidNum $Extend*; 100$MidLetterEx = $MidLetter $Extend*; 101$SufixLetterEx= $SufixLetter $Extend*; 102$KatakanaEx = $Katakana $Extend*; 103$IdeographicEx= $Ideographic $Extend*; 104$HangulEx = $Hangul $Extend*; 105$FormatEx = $Format $Extend*; 106 107 108# 109# Numbers. Rules 8, 11, 12 form the TR. 110# 111$NumberSequence = $NumericEx ($FormatEx* $MidNumEx? $FormatEx* $NumericEx)*; 112$NumberSequence {100}; 113 114# 115# Words. Alpha-numerics. Rule 5, 6, 7, 9, 10 116# - must include at least one letter. 117# - may include both letters and numbers. 118# - may include MideLetter, MidNumber punctuation. 119# 120$LetterSequence = $ALetterEx ($FormatEx* $MidLetterEx? $FormatEx* $ALetterEx)*; # rules #6, #7 121($NumberSequence $FormatEx*)? $LetterSequence ($FormatEx* ($NumberSequence | $LetterSequence))* $SufixLetterEx? {200}; 122 123[[:P:][:S:]]*; 124 125# 126# Do not break between Katakana. Rule #13. 127# 128$KatakanaEx ($FormatEx* $KatakanaEx)* {300}; 129[:Hiragana:] $Extend* {300}; 130 131# 132# Ideographic Characters. Stand by themselves as words. 133# Separated from the "Everything Else" rule, below, only so that they 134# can be tagged with a return value. TODO: is this what we want? 135# 136$IdeographicEx ($FormatEx* $IdeographicEx)* {400}; 137$HangulEx ($FormatEx* $HangulEx)* {400}; 138 139# 140# Everything Else, with no tag. 141# Non-Control chars combine with $Extend (combining) chars. 142# Controls are do not. 143# 144[^$Control [:Ideographic:]] $Extend*; 145$CR $LF; 146 147# 148# Reverse Rules. Back up over any of the chars that can group together. 149# (Reverse rules do not need to be exact; they can back up too far, 150# but must back up at least enough, and must stop on a boundary.) 151# 152 153# NonStarters are the set of all characters that can appear at the 2nd - nth position of 154# a word. (They may also be the first.) The reverse rule skips over these, until it 155# reaches something that can only be the start (and probably only) char in a "word". 156# A space or punctuation meets the test. 157# 158$NonStarters = [$Numeric $ALetter $Katakana $Ideographic $Hangul [:P:] [:S:] $MidLetter $MidNum $SufixLetter $Extend $Format]; 159 160#!.*; 161! ($NonStarters* | \n \r) .; 162 163