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
25$ALetter   = [\u0002 [:Alphabetic:] [:name= COMMERCIAL AT:] [:name= HEBREW PUNCTUATION GERESH:]
26                           - $Katakana
27                           - [:Script = Thai:]
28                           - [:Script = Lao:]
29                           - [:Script = Hiragana:]];
30
31$MidLetter = [[:name = QUOTATION MARK:] [:name = APOSTROPHE:] [:name = GRAVE ACCENT:] \u0084 [:name = SOFT HYPHEN:] [:name = MIDDLE DOT:] [:name = GREEK TONOS:] [:name= FULL STOP:]
32              [:name = HEBREW PUNCTUATION GERSHAYIM:] [:name = DOUBLE VERTICAL LINE:] [:name = LEFT SINGLE QUOTATION MARK:]
33              [:name = RIGHT SINGLE QUOTATION MARK:] [:name = HYPHENATION POINT:] [:name = PRIME:] [:name = HYPHEN-MINUS:]];
34
35$SufixLetter = [:name= FULL STOP:];
36
37$MidNum    = [[:LineBreak = Infix_Numeric:] [:name= COMMERCIAL AT:] \u0084 [:name = GREEK TONOS:] [:name = ARABIC DECIMAL SEPARATOR:]
38             [:name = LEFT SINGLE QUOTATION MARK:] [:name = RIGHT SINGLE QUOTATION MARK:] [:name = SINGLE HIGH-REVERSED-9 QUOTATION MARK:]
39             [:name = PRIME:]];
40$Numeric   = [:LineBreak = Numeric:];
41
42
43$TheZWSP = \u200b;
44
45#
46#  Character Class Definitions.
47#    The names are those from TR29.
48#
49$CR         = \u000d;
50$LF         = \u000a;
51$Control    = [[[:Zl:] [:Zp:] [:Cc:] [:Cf:]] - $TheZWSP];
52$Extend     = [[:Grapheme_Extend = TRUE:]];
53
54
55
56
57####################################################################################
58#
59#  Word Break Rules.    Definitions and Rules specific to word break begin Here.
60#
61####################################################################################
62
63$Format    = [[:Cf:] - $TheZWSP];
64
65
66
67# Rule 3:  Treat a grapheme cluster as if it were a single character.
68#          Hangul Syllables are easier to deal with here than they are in Grapheme Clusters
69#          because we don't need to find the boundaries between adjacent syllables -
70#          they won't be word boundaries.
71#
72
73
74#
75#  "Extended"  definitions.  Grapheme Cluster + Format Chars, treated like the base char.
76#
77$ALetterEx    = $ALetter   $Extend*;
78$NumericEx    = $Numeric   $Extend*;
79$MidNumEx     = $MidNum    $Extend*;
80$MidLetterEx  = $MidLetter $Extend*;
81$SufixLetterEx= $SufixLetter $Extend*;
82$KatakanaEx   = $Katakana  $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))* $SufixLetterEx? {200};
100
101[[:P:][:S:]]*;
102
103#
104#  Do not break between Katakana.   Rule #13.
105#
106$KatakanaEx ($FormatEx* $KatakanaEx)* {300};
107[:Hiragana:] $Extend* {300};
108
109#
110#  Ideographic Characters.  Stand by themselves as words.
111#                           Separated from the "Everything Else" rule, below, only so that they
112#                           can be tagged with a return value.   TODO:  is this what we want?
113#
114# [:IDEOGRAPHIC:] $Extend* {400};
115
116#
117#  Everything Else, with no tag.
118#                   Non-Control chars combine with $Extend (combining) chars.
119#                   Controls are do not.
120#
121[^$Control [:Ideographic:]] $Extend*;
122$CR $LF;
123
124#
125#  Reverse Rules.   Back up over any of the chars that can group together.
126#                   (Reverse rules do not need to be exact; they can back up  too far,
127#                   but must back up at least enough, and must stop on a boundary.)
128#
129
130# NonStarters are the set of all characters that can appear at the 2nd - nth position of
131#    a word.   (They may also be the first.)   The reverse rule skips over these, until it
132#    reaches something that can only be the start (and probably only) char in a "word".
133#    A space or punctuation meets the test.
134#
135$NonStarters = [$Numeric $ALetter $Katakana [:P:] [:S:] $MidLetter $MidNum $SufixLetter $Extend $Format];
136
137#!.*;
138! ($NonStarters* | \n \r) .;
139
140