Home | History | Annotate | Download | only in rules
      1 # Copyright (C) 2016 and later: Unicode, Inc. and others.
      2 # License & terms of use: http://www.unicode.org/copyright.html
      3 #
      4 #
      5 #   Copyright (C) 2002-2015, International Business Machines Corporation and others.
      6 #       All Rights Reserved.
      7 #
      8 #   file:  sent_el.txt
      9 #
     10 #   ICU Sentence Break Rules
     11 #      See Unicode Standard Annex #29.
     12 #      These rules are based on UAX #29 Revision 26 for Unicode Version 8.0
     13 #
     14 
     15 !!quoted_literals_only;
     16 
     17 #
     18 # Character categories as defined in TR 29
     19 #
     20 $CR        = [\p{Sentence_Break = CR}];
     21 $LF        = [\p{Sentence_Break = LF}];
     22 $Extend    = [\p{Sentence_Break = Extend}];
     23 $Sep       = [\p{Sentence_Break = Sep}];
     24 $Format    = [\p{Sentence_Break = Format}];
     25 $Sp        = [\p{Sentence_Break = Sp}];
     26 $Lower     = [\p{Sentence_Break = Lower}];
     27 $Upper     = [\p{Sentence_Break = Upper}];
     28 $OLetter   = [\p{Sentence_Break = OLetter}];
     29 $Numeric   = [\p{Sentence_Break = Numeric}];
     30 $ATerm     = [\p{Sentence_Break = ATerm}];
     31 $SContinue = [\p{Sentence_Break = SContinue}];
     32 $STerm     = [\p{Sentence_Break = STerm} [\u003B \u037E]];
     33 $Close     = [\p{Sentence_Break = Close}];
     34 
     35 #
     36 # Define extended forms of the character classes,
     37 #   incorporate trailing Extend or Format chars.
     38 #   Rules 4 and 5.  
     39 
     40 $SpEx       = $Sp      ($Extend | $Format)*;
     41 $LowerEx    = $Lower   ($Extend | $Format)*;
     42 $UpperEx    = $Upper   ($Extend | $Format)*;
     43 $OLetterEx  = $OLetter ($Extend | $Format)*;
     44 $NumericEx  = $Numeric ($Extend | $Format)*;
     45 $ATermEx    = $ATerm   ($Extend | $Format)*;
     46 $SContinueEx= $SContinue ($Extend | $Format)*;
     47 $STermEx    = $STerm   ($Extend | $Format)*;
     48 $CloseEx    = $Close   ($Extend | $Format)*;
     49 
     50 
     51 ## -------------------------------------------------
     52 
     53 !!chain;
     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
     70 ($UpperEx | $LowerEx) $ATermEx $UpperEx;
     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