2002-08-30 21:37:59 +00:00
|
|
|
#
|
2005-03-23 02:13:53 +00:00
|
|
|
# Copyright (C) 2002-2005, International Business Machines Corporation and others.
|
2002-08-30 21:37:59 +00:00
|
|
|
# All Rights Reserved.
|
|
|
|
#
|
2003-11-25 00:23:46 +00:00
|
|
|
# file: sent.txt
|
2002-08-30 21:37:59 +00:00
|
|
|
#
|
|
|
|
# ICU Sentence Break Rules
|
2003-05-16 22:05:35 +00:00
|
|
|
# See Unicode Standard Annex #29.
|
2005-09-15 23:23:24 +00:00
|
|
|
# These rules are based on TR 29 version 4.1.0
|
2002-08-30 21:37:59 +00:00
|
|
|
#
|
2003-11-25 00:23:46 +00:00
|
|
|
|
2002-06-25 17:23:07 +00:00
|
|
|
|
2002-08-30 21:37:59 +00:00
|
|
|
#
|
|
|
|
# Character categories as defined in TR 29
|
|
|
|
#
|
2005-04-22 21:49:52 +00:00
|
|
|
$Sep = [\p{Sentence_Break = Sep}];
|
|
|
|
$Format = [\p{Sentence_Break = Format}];
|
|
|
|
$Sp = [\p{Sentence_Break = Sp}];
|
|
|
|
$Lower = [\p{Sentence_Break = Lower}];
|
|
|
|
$Upper = [\p{Sentence_Break = Upper}];
|
|
|
|
$OLetter = [\p{Sentence_Break = OLetter}];
|
|
|
|
$Numeric = [\p{Sentence_Break = Numeric}];
|
|
|
|
$ATerm = [\p{Sentence_Break = ATerm}];
|
2005-09-15 23:23:24 +00:00
|
|
|
$STerm = [\p{Sentence_Break = STerm}];
|
2005-04-22 21:49:52 +00:00
|
|
|
$Close = [\p{Sentence_Break = Close}];
|
2005-09-26 23:56:32 +00:00
|
|
|
$Surrogate = [\p{GC=Surrogate}];
|
2003-11-05 23:50:39 +00:00
|
|
|
|
2005-04-22 21:49:52 +00:00
|
|
|
#
|
2003-11-09 06:52:44 +00:00
|
|
|
# Define extended forms of the character classes,
|
|
|
|
# incorporate grapheme cluster + format chars.
|
2005-09-15 23:23:24 +00:00
|
|
|
# Rules 4 and 5.
|
2002-08-30 21:37:59 +00:00
|
|
|
|
2005-09-15 23:23:24 +00:00
|
|
|
$CR = \u000d;
|
|
|
|
$LF = \u000a;
|
2003-11-25 00:23:46 +00:00
|
|
|
$Extend = [[:Grapheme_Extend = TRUE:]];
|
2005-09-15 23:23:24 +00:00
|
|
|
$Control = [\p{Grapheme_Cluster_Break = Control}];
|
2002-08-30 21:37:59 +00:00
|
|
|
|
2005-09-26 23:56:32 +00:00
|
|
|
$SpEx = ($Sp | ([[$Sp]-[$Control]] $Extend*)) $Format*;
|
2005-09-15 23:23:24 +00:00
|
|
|
$LowerEx = $Lower $Extend* $Format*;
|
|
|
|
$UpperEx = $Upper $Extend* $Format*;
|
|
|
|
$OLetterEx = $OLetter $Extend* $Format*;
|
|
|
|
$NumericEx = $Numeric $Extend* $Format*;
|
|
|
|
$ATermEx = $ATerm $Extend* $Format*;
|
|
|
|
$STermEx = $STerm $Extend* $Format*;
|
|
|
|
$CloseEx = $Close $Extend* $Format*;
|
2003-11-05 23:50:39 +00:00
|
|
|
|
2003-11-25 00:23:46 +00:00
|
|
|
|
2003-11-09 06:52:44 +00:00
|
|
|
## -------------------------------------------------
|
2002-06-25 17:23:07 +00:00
|
|
|
|
2005-09-15 23:23:24 +00:00
|
|
|
!!chain;
|
|
|
|
!!forward;
|
2003-11-09 20:32:00 +00:00
|
|
|
|
2005-09-26 23:56:32 +00:00
|
|
|
# Rule 3 - break after separators. Keep CR/LF together.
|
2005-09-15 23:23:24 +00:00
|
|
|
#
|
2005-09-26 23:56:32 +00:00
|
|
|
$CR $LF;
|
2003-11-09 20:32:00 +00:00
|
|
|
|
|
|
|
|
2005-09-15 23:23:24 +00:00
|
|
|
# Rule 4 - don't break grapheme clusters, including optional trailing format chars.
|
|
|
|
#
|
|
|
|
[^$Control $Sep] $Extend+ $Format*;
|
|
|
|
[^$Control $Sep] $Extend* $Format+;
|
2003-11-09 20:32:00 +00:00
|
|
|
|
|
|
|
|
2005-09-15 23:23:24 +00:00
|
|
|
# Rule 6
|
|
|
|
$ATermEx $NumericEx;
|
2003-11-09 20:32:00 +00:00
|
|
|
|
2005-09-15 23:23:24 +00:00
|
|
|
# Rule 7
|
|
|
|
$UpperEx $ATermEx $UpperEx;
|
2003-11-09 20:32:00 +00:00
|
|
|
|
2005-09-15 23:23:24 +00:00
|
|
|
#Rule 8
|
2005-09-26 23:56:32 +00:00
|
|
|
$NotLettersEx = ([^$OLetter $Upper $Lower $Sep $ATerm $STerm $Control] $Extend* $Format*) |
|
|
|
|
([^$OLetter $Upper $Lower $Sep $ATerm $STerm] $Format*);
|
2005-09-15 23:23:24 +00:00
|
|
|
$ATermEx $CloseEx* $SpEx* $NotLettersEx* $Lower;
|
2003-11-05 23:50:39 +00:00
|
|
|
|
2005-09-15 23:23:24 +00:00
|
|
|
#Rule 9, 10, 11
|
|
|
|
($STermEx | $ATermEx) $CloseEx* $SpEx* $Sep?;
|
2003-11-09 20:32:00 +00:00
|
|
|
|
2005-09-15 23:23:24 +00:00
|
|
|
#Rule 12
|
2005-09-26 23:56:32 +00:00
|
|
|
[[^$STerm $ATerm $Close $Sp $Sep $Format $Extend]{bof}] ($Extend | $Format | $Close | $Sp)* .;
|
|
|
|
[[^$STerm $ATerm $Close $Sp $Sep $Format $Extend]{bof}] ($Extend | $Format | $Close | $Sp)* ([$Sep{eof}] | $CR $LF){100};
|
2003-11-09 20:32:00 +00:00
|
|
|
|
2005-09-15 23:23:24 +00:00
|
|
|
## -------------------------------------------------
|
2003-11-09 20:32:00 +00:00
|
|
|
|
2005-09-15 23:23:24 +00:00
|
|
|
!!reverse;
|
2003-11-09 20:32:00 +00:00
|
|
|
|
2005-09-26 23:56:32 +00:00
|
|
|
$SpEx_R = $Format* ($Sp | ( $Extend+[[$Sp]-[$Control]]));
|
|
|
|
$LowerEx_R = $Format* $Extend* $Lower;
|
|
|
|
$UpperEx_R = $Format* $Extend* $Upper;
|
|
|
|
$OLetterEx_R = $Format* $Extend* $OLetter;
|
|
|
|
$NumericEx_R = $Format* $Extend* $Numeric;
|
|
|
|
$ATermEx_R = $Format* $Extend* $ATerm;
|
|
|
|
$STermEx_R = $Format* $Extend* $STerm;
|
|
|
|
$CloseEx_R = $Format* $Extend* $Close;
|
2003-11-25 00:23:46 +00:00
|
|
|
|
2005-09-26 23:56:32 +00:00
|
|
|
#
|
|
|
|
# Reverse rules.
|
|
|
|
# For now, use the old style inexact reverse rules, which are easier
|
|
|
|
# to write, but less efficient.
|
|
|
|
# TODO: exact reverse rules. It appears that exact reverse rules
|
|
|
|
# may require improving support for look-ahead breaks in the
|
|
|
|
# builder. Needs more investigation.
|
|
|
|
#
|
2005-09-27 18:21:18 +00:00
|
|
|
[{bof}] [^$Sep]* ($Sep | $LF $CR) [^$Sep]* [$Sep {eof}] ($SpEx_R* $CloseEx_R* ($STermEx_R | $ATermEx_R))?;
|
2003-11-09 20:32:00 +00:00
|
|
|
|
|
|
|
|