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