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