]>
Commit | Line | Data |
---|---|---|
46f4442e | 1 | # |
f3c0d7a5 A |
2 | # Copyright (C) 2016 and later: Unicode, Inc. and others. |
3 | # License & terms of use: http://www.unicode.org/copyright.html#License | |
4 | # | |
2ca993e8 | 5 | # Copyright (C) 2002-2015, International Business Machines Corporation and others. |
46f4442e A |
6 | # All Rights Reserved. |
7 | # | |
8 | # file: sent_el.txt | |
9 | # | |
10 | # ICU Sentence Break Rules | |
11 | # See Unicode Standard Annex #29. | |
2ca993e8 | 12 | # These rules are based on UAX #29 Revision 26 for Unicode Version 8.0 |
46f4442e A |
13 | # |
14 | ||
15 | ||
16 | # | |
17 | # Character categories as defined in TR 29 | |
18 | # | |
19 | $CR = [\p{Sentence_Break = CR}]; | |
20 | $LF = [\p{Sentence_Break = LF}]; | |
21 | $Extend = [\p{Sentence_Break = Extend}]; | |
22 | $Sep = [\p{Sentence_Break = Sep}]; | |
23 | $Format = [\p{Sentence_Break = Format}]; | |
24 | $Sp = [\p{Sentence_Break = Sp}]; | |
25 | $Lower = [\p{Sentence_Break = Lower}]; | |
26 | $Upper = [\p{Sentence_Break = Upper}]; | |
27 | $OLetter = [\p{Sentence_Break = OLetter}]; | |
28 | $Numeric = [\p{Sentence_Break = Numeric}]; | |
29 | $ATerm = [\p{Sentence_Break = ATerm}]; | |
30 | $SContinue = [\p{Sentence_Break = SContinue}]; | |
31 | $STerm = [\p{Sentence_Break = STerm} [\u003B \u037E]]; | |
32 | $Close = [\p{Sentence_Break = Close}]; | |
33 | ||
34 | # | |
35 | # Define extended forms of the character classes, | |
36 | # incorporate trailing Extend or Format chars. | |
37 | # Rules 4 and 5. | |
38 | ||
39 | $SpEx = $Sp ($Extend | $Format)*; | |
40 | $LowerEx = $Lower ($Extend | $Format)*; | |
41 | $UpperEx = $Upper ($Extend | $Format)*; | |
42 | $OLetterEx = $OLetter ($Extend | $Format)*; | |
43 | $NumericEx = $Numeric ($Extend | $Format)*; | |
44 | $ATermEx = $ATerm ($Extend | $Format)*; | |
45 | $SContinueEx= $SContinue ($Extend | $Format)*; | |
46 | $STermEx = $STerm ($Extend | $Format)*; | |
47 | $CloseEx = $Close ($Extend | $Format)*; | |
48 | ||
49 | ||
50 | ## ------------------------------------------------- | |
51 | ||
52 | !!chain; | |
53 | !!forward; | |
54 | ||
55 | # Rule 3 - break after separators. Keep CR/LF together. | |
56 | # | |
57 | $CR $LF; | |
58 | ||
59 | ||
60 | # Rule 4 - Break after $Sep. | |
61 | # Rule 5 - Ignore $Format and $Extend | |
62 | # | |
63 | [^$Sep $CR $LF]? ($Extend | $Format)*; | |
64 | ||
65 | ||
66 | # Rule 6 | |
67 | $ATermEx $NumericEx; | |
68 | ||
69 | # Rule 7 | |
2ca993e8 | 70 | ($UpperEx | $LowerEx) $ATermEx $UpperEx; |
46f4442e A |
71 | |
72 | #Rule 8 | |
73 | $NotLettersEx = [^$OLetter $Upper $Lower $Sep $CR $LF $ATerm $STerm] ($Extend | $Format)*; | |
74 | $ATermEx $CloseEx* $SpEx* $NotLettersEx* $Lower; | |
75 | ||
76 | # Rule 8a | |
77 | ($STermEx | $ATermEx) $CloseEx* $SpEx* ($SContinueEx | $STermEx | $ATermEx); | |
78 | ||
79 | #Rule 9, 10, 11 | |
80 | ($STermEx | $ATermEx) $CloseEx* $SpEx* ($Sep | $CR | $LF)?; | |
81 | ||
82 | #Rule 12 | |
83 | [[^$STerm $ATerm $Close $Sp $Sep $LF $CR $Format $Extend]{bof}] ($Extend | $Format | $Close | $Sp)* .; | |
84 | [[^$STerm $ATerm $Close $Sp $Sep $LF $CR $Format $Extend]{bof}] ($Extend | $Format | $Close | $Sp)* ([$Sep $LF $CR {eof}] | $CR $LF){100}; | |
85 | ||
86 | ## ------------------------------------------------- | |
87 | ||
88 | !!reverse; | |
89 | ||
90 | $SpEx_R = ($Extend | $Format)* $Sp; | |
91 | $ATermEx_R = ($Extend | $Format)* $ATerm; | |
92 | $STermEx_R = ($Extend | $Format)* $STerm; | |
93 | $CloseEx_R = ($Extend | $Format)* $Close; | |
94 | ||
95 | # | |
96 | # Reverse rules. | |
97 | # For now, use the old style inexact reverse rules, which are easier | |
98 | # to write, but less efficient. | |
99 | # TODO: exact reverse rules. It appears that exact reverse rules | |
100 | # may require improving support for look-ahead breaks in the | |
101 | # builder. Needs more investigation. | |
102 | # | |
103 | ||
104 | [{bof}] (.? | $LF $CR) [^$Sep $CR $LF]* [$Sep $CR $LF {eof}] ($SpEx_R* $CloseEx_R* ($STermEx_R | $ATermEx_R))*; | |
105 | #.*; | |
106 | ||
107 | # Explanation for this rule: | |
108 | # | |
109 | # It needs to back over | |
110 | # The $Sep at which we probably begin | |
111 | # All of the non $Sep chars leading to the preceding $Sep | |
112 | # The preceding $Sep, which will be the second one that the rule matches. | |
113 | # Any immediately preceding STerm or ATerm sequences. We need to see these | |
114 | # to get the correct rule status when moving forwards again. | |
115 | # | |
116 | # [{bof}] inhibit rule chaining. Without this, rule would loop on itself and match | |
117 | # the entire string. | |
118 | # | |
119 | # (.? | $LF $CR) Match one $Sep instance. Use .? rather than $Sep because position might be | |
120 | # at the beginning of the string at this point, and we don't want to fail. | |
121 | # Can only use {eof} once, and it is used later. | |
122 | # |