Skip to content

Commit

Permalink
ICU-22112 word break updates for @,colon; colon tailorings for fi,sv
Browse files Browse the repository at this point in the history
See #2159
  • Loading branch information
pedberg-icu committed Aug 23, 2022
1 parent 8c669a7 commit 49d192f
Show file tree
Hide file tree
Showing 18 changed files with 301 additions and 24 deletions.
8 changes: 8 additions & 0 deletions icu4c/source/data/brkitr/fi.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
// Generated using tools/cldr/cldr-to-icu/build-icu-data.xml
fi{
boundaries{
word:process(dependency){"word_fi_sv.brk"}
}
}
6 changes: 3 additions & 3 deletions icu4c/source/data/brkitr/rules/word.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# These rules are based on UAX #29 Revision 34 for Unicode Version 12.0
#
# Note: Updates to word.txt will usually need to be merged into
# word_POSIX.txt also.
# word_POSIX.txt and word_fi_sv.txt also.

##############################################################################
#
Expand All @@ -38,11 +38,11 @@ $Regional_Indicator = [\p{Word_Break = Regional_Indicator}];
$Format = [\p{Word_Break = Format}];
$Katakana = [\p{Word_Break = Katakana}];
$Hebrew_Letter = [\p{Word_Break = Hebrew_Letter}];
$ALetter = [\p{Word_Break = ALetter}];
$ALetter = [\p{Word_Break = ALetter} @];
$Single_Quote = [\p{Word_Break = Single_Quote}];
$Double_Quote = [\p{Word_Break = Double_Quote}];
$MidNumLet = [\p{Word_Break = MidNumLet}];
$MidLetter = [\p{Word_Break = MidLetter}];
$MidLetter = [\p{Word_Break = MidLetter} - [\: \uFE55 \uFF1A]];
$MidNum = [\p{Word_Break = MidNum}];
$Numeric = [\p{Word_Break = Numeric}];
$ExtendNumLet = [\p{Word_Break = ExtendNumLet}];
Expand Down
4 changes: 2 additions & 2 deletions icu4c/source/data/brkitr/rules/word_POSIX.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ $Regional_Indicator = [\p{Word_Break = Regional_Indicator}];
$Format = [\p{Word_Break = Format}];
$Katakana = [\p{Word_Break = Katakana}];
$Hebrew_Letter = [\p{Word_Break = Hebrew_Letter}];
$ALetter = [\p{Word_Break = ALetter}];
$ALetter = [\p{Word_Break = ALetter} @];
$Single_Quote = [\p{Word_Break = Single_Quote}];
$Double_Quote = [\p{Word_Break = Double_Quote}];
$MidNumLet = [\p{Word_Break = MidNumLet} - [.]];
$MidLetter = [\p{Word_Break = MidLetter} - [\:]];
$MidLetter = [\p{Word_Break = MidLetter} - [\: \uFE55 \uFF1A]];
$MidNum = [\p{Word_Break = MidNum} [.]];
$Numeric = [\p{Word_Break = Numeric}];
$ExtendNumLet = [\p{Word_Break = ExtendNumLet}];
Expand Down
172 changes: 172 additions & 0 deletions icu4c/source/data/brkitr/rules/word_fi_sv.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,172 @@
#
# Copyright (C) 2016 and later: Unicode, Inc. and others.
# License & terms of use: http://www.unicode.org/copyright.html
# Copyright (C) 2002-2016, International Business Machines Corporation
# and others. All Rights Reserved.
#
# file: word_fi_sv.txt
#
# ICU Word Break Rules
# See Unicode Standard Annex #29.
# These rules are based on UAX #29 Revision 34 for Unicode Version 12.0
#
# Note: Updates to word.txt will usually need to be merged into
# word_fi_sv.txt also.

##############################################################################
#
# Character class definitions from TR 29
#
##############################################################################

!!chain;
!!quoted_literals_only;


#
# Character Class Definitions.
#

$Han = [:Han:];

$CR = [\p{Word_Break = CR}];
$LF = [\p{Word_Break = LF}];
$Newline = [\p{Word_Break = Newline}];
$Extend = [\p{Word_Break = Extend}-$Han];
$ZWJ = [\p{Word_Break = ZWJ}];
$Regional_Indicator = [\p{Word_Break = Regional_Indicator}];
$Format = [\p{Word_Break = Format}];
$Katakana = [\p{Word_Break = Katakana}];
$Hebrew_Letter = [\p{Word_Break = Hebrew_Letter}];
$ALetter = [\p{Word_Break = ALetter} @];
$Single_Quote = [\p{Word_Break = Single_Quote}];
$Double_Quote = [\p{Word_Break = Double_Quote}];
$MidNumLet = [\p{Word_Break = MidNumLet}];
$MidLetter = [\p{Word_Break = MidLetter}];
$MidNum = [\p{Word_Break = MidNum}];
$Numeric = [\p{Word_Break = Numeric}];
$ExtendNumLet = [\p{Word_Break = ExtendNumLet}];
$WSegSpace = [\p{Word_Break = WSegSpace}];
$Extended_Pict = [\p{Extended_Pictographic}];

$Hiragana = [:Hiragana:];
$Ideographic = [\p{Ideographic}];


# Dictionary character set, for triggering language-based break engines. Currently
# limited to LineBreak=Complex_Context. Note that this set only works in Unicode
# 5.0 or later as the definition of Complex_Context was corrected to include all
# characters requiring dictionary break.

$Control = [\p{Grapheme_Cluster_Break = Control}];
$HangulSyllable = [\uac00-\ud7a3];
$ComplexContext = [:LineBreak = Complex_Context:];
$KanaKanji = [$Han $Hiragana $Katakana];
$dictionaryCJK = [$KanaKanji $HangulSyllable];
$dictionary = [$ComplexContext $dictionaryCJK];

# TODO: check if handling of katakana in dictionary makes rules incorrect/void

# leave CJK scripts out of ALetterPlus
$ALetterPlus = [$ALetter-$dictionaryCJK [$ComplexContext-$Extend-$Control]];


## -------------------------------------------------

# Rule 3 - CR x LF
#
$CR $LF;

# Rule 3c Do not break within emoji zwj sequences.
# ZWJ × \p{Extended_Pictographic}. Precedes WB4, so no intervening Extend chars allowed.
#
$ZWJ $Extended_Pict;

# Rule 3d - Keep horizontal whitespace together.
#
$WSegSpace $WSegSpace;

# Rule 4 - ignore Format and Extend characters, except when they appear at the beginning
# of a region of Text.

$ExFm = [$Extend $Format $ZWJ];

^$ExFm+; # This rule fires only when there are format or extend characters at the
# start of text, or immediately following another boundary. It groups them, in
# the event there are more than one.

[^$CR $LF $Newline $ExFm] $ExFm*; # This rule rule attaches trailing format/extends to words,
# with no special rule status value.

$Numeric $ExFm* {100}; # This group of rules also attach trailing format/extends, but
$ALetterPlus $ExFm* {200}; # with rule status set based on the word's final base character.
$HangulSyllable {200};
$Hebrew_Letter $ExFm* {200};
$Katakana $ExFm* {400}; # note: these status values override those from rule 5
$Hiragana $ExFm* {400}; # by virtue of being numerically larger.
$Ideographic $ExFm* {400}; #

#
# rule 5
# Do not break between most letters.
#
($ALetterPlus | $Hebrew_Letter) $ExFm* ($ALetterPlus | $Hebrew_Letter);

# rule 6 and 7
($ALetterPlus | $Hebrew_Letter) $ExFm* ($MidLetter | $MidNumLet | $Single_Quote) $ExFm* ($ALetterPlus | $Hebrew_Letter) {200};

# rule 7a
$Hebrew_Letter $ExFm* $Single_Quote {200};

# rule 7b and 7c
$Hebrew_Letter $ExFm* $Double_Quote $ExFm* $Hebrew_Letter;

# rule 8

$Numeric $ExFm* $Numeric;

# rule 9

($ALetterPlus | $Hebrew_Letter) $ExFm* $Numeric;

# rule 10

$Numeric $ExFm* ($ALetterPlus | $Hebrew_Letter);

# rule 11 and 12

$Numeric $ExFm* ($MidNum | $MidNumLet | $Single_Quote) $ExFm* $Numeric;

# rule 13
# to be consistent with $KanaKanji $KanaKanhi, changed
# from 300 to 400.
# See also TestRuleStatus in intltest/rbbiapts.cpp
$Katakana $ExFm* $Katakana {400};

# rule 13a/b

$ALetterPlus $ExFm* $ExtendNumLet {200}; # (13a)
$Hebrew_Letter $ExFm* $ExtendNumLet {200}; # (13a)
$Numeric $ExFm* $ExtendNumLet {100}; # (13a)
$Katakana $ExFm* $ExtendNumLet {400}; # (13a)
$ExtendNumLet $ExFm* $ExtendNumLet {200}; # (13a)

$ExtendNumLet $ExFm* $ALetterPlus {200}; # (13b)
$ExtendNumLet $ExFm* $Hebrew_Letter {200}; # (13b)
$ExtendNumLet $ExFm* $Numeric {100}; # (13b)
$ExtendNumLet $ExFm* $Katakana {400}; # (13b)

# rules 15 - 17
# Pairs of Regional Indicators stay together.
# With incoming rule chaining disabled by ^, this rule will match exactly two of them.
# No other rule begins with a Regional_Indicator, so chaining cannot extend the match.
#
^$Regional_Indicator $ExFm* $Regional_Indicator;

# special handling for CJK characters: chain for later dictionary segmentation
$HangulSyllable $HangulSyllable {200};
$KanaKanji $KanaKanji {400}; # different rule status if both kana and kanji found

# Rule 999
# Match a single code point if no other rule applies.
.;
8 changes: 8 additions & 0 deletions icu4c/source/data/brkitr/sv.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
// Generated using tools/cldr/cldr-to-icu/build-icu-data.xml
sv{
boundaries{
word:process(dependency){"word_fi_sv.brk"}
}
}
26 changes: 26 additions & 0 deletions icu4c/source/data/xml/brkitr/fi.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright (C) 2016 and later: Unicode, Inc. and others.
License & terms of use: http://www.unicode.org/copyright.html
Copyright (c) 2010-2015 International Business Machines Corporation and others. All rights reserved.
-->
<!DOCTYPE ldml SYSTEM "../../dtd/cldr/common/dtd/ldml.dtd"
[
<!ENTITY % icu SYSTEM "../../dtd/cldr/common/dtd/ldmlICU.dtd">
%icu;
]
>
<ldml>
<identity>
<version number="$Revision$"/>
<language type="fi"/>
</identity>
<special xmlns:icu="http://www.icu-project.org/">
<icu:breakIteratorData>
<icu:boundaries>
<icu:word icu:dependency="word_fi_sv.brk"/>
</icu:boundaries>
</icu:breakIteratorData>
</special>
</ldml>

26 changes: 26 additions & 0 deletions icu4c/source/data/xml/brkitr/sv.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!--
Copyright (C) 2016 and later: Unicode, Inc. and others.
License & terms of use: http://www.unicode.org/copyright.html
Copyright (c) 2010-2015 International Business Machines Corporation and others. All rights reserved.
-->
<!DOCTYPE ldml SYSTEM "../../dtd/cldr/common/dtd/ldml.dtd"
[
<!ENTITY % icu SYSTEM "../../dtd/cldr/common/dtd/ldmlICU.dtd">
%icu;
]
>
<ldml>
<identity>
<version number="$Revision$"/>
<language type="sv"/>
</identity>
<special xmlns:icu="http://www.icu-project.org/">
<icu:breakIteratorData>
<icu:boundaries>
<icu:word icu:dependency="word_fi_sv.brk"/>
</icu:boundaries>
</icu:breakIteratorData>
</special>
</ldml>

11 changes: 8 additions & 3 deletions icu4c/source/test/intltest/rbbitst.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1264,12 +1264,17 @@ UBool RBBITest::testCaseIsKnownIssue(const UnicodeString &testCase, const char *
{"21097", "LineBreakTest.txt", u"\uBD10\uC694\u002E\u0020\u0041\u002E\u0033\u0020\uBABB"},
{"21097", "LineBreakTest.txt", u"\uC694\u002E\u0020\u0041\u002E\u0034\u0020\uBABB"},
{"21097", "LineBreakTest.txt", u"a.2\u3000\u300C"},

// ICU-22127 until UAX #29 wordbreak is update for the colon changes in ICU-22112,
// need to skip some tests in WordBreakTest.txt
{"22127", "WordBreakTest.txt", u"a:"},
{"22127", "WordBreakTest.txt", u"A:"},
};

for (int n=0; n<UPRV_LENGTHOF(badTestCases); n++) {
const TestCase &badCase = badTestCases[n];
if (!strcmp(fileName, badCase.fFileName) &&
testCase == UnicodeString(badCase.fString)) {
testCase.startsWith(UnicodeString(badCase.fString))) {
return logKnownIssue(badCase.fTicketNum);
}
}
Expand Down Expand Up @@ -1912,11 +1917,11 @@ RBBIWordMonkey::RBBIWordMonkey()
fKatakanaSet = new UnicodeSet(u"[\\p{Word_Break = Katakana}]", status);
fRegionalIndicatorSet = new UnicodeSet(u"[\\p{Word_Break = Regional_Indicator}]", status);
fHebrew_LetterSet = new UnicodeSet(u"[\\p{Word_Break = Hebrew_Letter}]", status);
fALetterSet = new UnicodeSet(u"[\\p{Word_Break = ALetter}]", status);
fALetterSet = new UnicodeSet(u"[\\p{Word_Break = ALetter} @]", status);
fSingle_QuoteSet = new UnicodeSet(u"[\\p{Word_Break = Single_Quote}]", status);
fDouble_QuoteSet = new UnicodeSet(u"[\\p{Word_Break = Double_Quote}]", status);
fMidNumLetSet = new UnicodeSet(u"[\\p{Word_Break = MidNumLet}]", status);
fMidLetterSet = new UnicodeSet(u"[\\p{Word_Break = MidLetter}]", status);
fMidLetterSet = new UnicodeSet(u"[\\p{Word_Break = MidLetter} - [\\: \\uFE55 \\uFF1A]]", status);
fMidNumSet = new UnicodeSet(u"[\\p{Word_Break = MidNum}]", status);
fNumericSet = new UnicodeSet(u"[\\p{Word_Break = Numeric}]", status);
fFormatSet = new UnicodeSet(u"[\\p{Word_Break = Format}]", status);
Expand Down
4 changes: 2 additions & 2 deletions icu4c/source/test/testdata/break_rules/word.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ Regional_Indicator = [\p{Word_Break = Regional_Indicator}];
Format = [\p{Word_Break = Format}];
Katakana = [\p{Word_Break = Katakana}];
Hebrew_Letter = [\p{Word_Break = Hebrew_Letter}];
ALetter = [\p{Word_Break = ALetter}];
ALetter = [\p{Word_Break = ALetter} @];
Single_Quote = [\p{Word_Break = Single_Quote}];
Double_Quote = [\p{Word_Break = Double_Quote}];
MidNumLet = [\p{Word_Break = MidNumLet}];
MidLetter = [\p{Word_Break = MidLetter}];
MidLetter = [\p{Word_Break = MidLetter} - [\: \uFE55 \uFF1A]];
MidNum = [\p{Word_Break = MidNum}];
Numeric = [\p{Word_Break = Numeric}];
ExtendNumLet = [\p{Word_Break = ExtendNumLet}];
Expand Down
2 changes: 1 addition & 1 deletion icu4c/source/test/testdata/break_rules/word_POSIX.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ALetter = [\p{Word_Break = ALetter}];
Single_Quote = [\p{Word_Break = Single_Quote}];
Double_Quote = [\p{Word_Break = Double_Quote}];
MidNumLet = [\p{Word_Break = MidNumLet} - [.]];
MidLetter = [\p{Word_Break = MidLetter} - [\:]];
MidLetter = [\p{Word_Break = MidLetter} - [\: \uFE55 \uFF1A]];
MidNum = [\p{Word_Break = MidNum} [.]];
Numeric = [\p{Word_Break = Numeric}];
ExtendNumLet = [\p{Word_Break = ExtendNumLet}];
Expand Down
18 changes: 17 additions & 1 deletion icu4c/source/test/testdata/rbbitst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1583,16 +1583,32 @@ Bangkok)•</data>

<locale en_US>
<word>
<data>•Can't<200> •have<200> •breaks<200> •in<200> •xx:yy<200> •or<200> •struct.field<200> \
<data>•Can't<200> •have<200> •breaks<200> •in<200> •xx<200>:•yy<200> •or<200> •struct.field<200> \
•for<200> •CS<200>-•types<200>.•</data>
<data>•\uFF92\uFF76\uFF9E<400> •</data>
<data>•xx@yy<200>.•</data>

<locale en_US_POSIX>
<word>
<data>•Can't<200> •have<200> •breaks<200> •in<200> •xx<200>:•yy<200> •or<200> •struct<200>.•field<200> \
•for<200> •CS<200>-•types<200>.•</data>
<data>•\u06c9<200>\uc799\ufffa•</data>
<data>•\uFF92\uFF76\uFF9E<400> •</data>
<data>•xx@yy<200>.•</data>

<locale fi>
<word>
<data>•Can't<200> •have<200> •breaks<200> •in<200> •xx:yy<200> •or<200> •struct.field<200> \
•for<200> •CS<200>-•types<200>.•</data>
<data>•\uFF92\uFF76\uFF9E<400> •</data>
<data>•xx@yy<200>.•</data>

<locale sv>
<word>
<data>•Can't<200> •have<200> •breaks<200> •in<200> •xx:yy<200> •or<200> •struct.field<200> \
•for<200> •CS<200>-•types<200>.•</data>
<data>•\uFF92\uFF76\uFF9E<400> •</data>
<data>•xx@yy<200>.•</data>


# UBreakIteratorType UBRK_CHARACTER, Locale "th"
Expand Down
4 changes: 2 additions & 2 deletions icu4j/main/shared/data/icudata.jar
Git LFS file not shown
4 changes: 2 additions & 2 deletions icu4j/main/shared/data/icutzdata.jar
Git LFS file not shown
4 changes: 2 additions & 2 deletions icu4j/main/shared/data/testdata.jar
Git LFS file not shown
Loading

0 comments on commit 49d192f

Please sign in to comment.