Skip to content

Commit

Permalink
CLDR-11155 Pages too big; move some paths to new Pages
Browse files Browse the repository at this point in the history
-New Travel_Places2 (Travel & Places 2) starting with subgroup money

-New Objects2 starting with subgroup other-symbol

-New Punctuation, MathSymbols, OtherSymbols, replacing Symbols2

-New unit test TestAnnotations.testSymbols

-Fix some compiler warnings including dead code

-Comments, including TODO for Volume/Volume2 (not emoji)
  • Loading branch information
btangmu committed Feb 16, 2024
1 parent 52114b4 commit 801cedc
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,11 @@ public static PageId getPageId(String emoji) {
case Symbols:
return (minorOrder < minorToOrder.get("transport-sign"))
? PageId.Symbols
: (minorOrder < minorToOrder.get("other-symbol"))
? PageId.Symbols2
: PageId.Symbols3;
: (minorOrder < minorToOrder.get("math"))
? PageId.EmojiSymbols
: (minorOrder < minorToOrder.get("other-symbol"))
? PageId.MathSymbols
: PageId.OtherSymbols;
case Travel_Places:
return (minorOrder < minorToOrder.get("transport-ground"))
? PageId.Travel_Places
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,8 +320,9 @@ public enum PageId {
Activities(SectionId.Characters),
Objects(SectionId.Characters),
Objects2(SectionId.Characters),
Symbols2(SectionId.Characters),
Symbols3(SectionId.Characters),
EmojiSymbols(SectionId.Characters, "Emoji Symbols"),
MathSymbols(SectionId.Characters, "Math Symbols"),
OtherSymbols(SectionId.Characters, "Other Symbols"),
Flags(SectionId.Characters),
Component(SectionId.Characters),
Typography(SectionId.Characters),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,14 @@
import org.unicode.cldr.util.Emoji;
import org.unicode.cldr.util.Factory;
import org.unicode.cldr.util.Level;
import org.unicode.cldr.util.Pair;
import org.unicode.cldr.util.PathHeader;
import org.unicode.cldr.util.PathHeader.PageId;
import org.unicode.cldr.util.SimpleFactory;
import org.unicode.cldr.util.SupplementalDataInfo;
import org.unicode.cldr.util.XListFormatter;
import org.unicode.cldr.util.XListFormatter.ListTypeLength;
import org.unicode.cldr.util.XPathParts;

public class TestAnnotations extends TestFmwkPlus {
private static final String APPS_EMOJI_DIRECTORY =
Expand Down Expand Up @@ -234,7 +237,7 @@ public void TestCategories() {
final String rawCategory = Emoji.getMajorCategory(emoji);
PageId majorCategory = PageId.forString(rawCategory);
if (majorCategory == PageId.Symbols) {
majorCategory = PageId.Symbols2;
majorCategory = PageId.EmojiSymbols;
}
String minorCategory = Emoji.getMinorCategory(emoji);
long emojiOrder = Emoji.getEmojiToOrder(emoji);
Expand Down Expand Up @@ -618,4 +621,64 @@ public void testCoverage() {
}
}
}

static final UnicodeSet allRgiNoES = Emoji.getAllRgiNoES();
static final UnicodeSet punctuation = new UnicodeSet("[:P:]").freeze();
static final UnicodeSet mathSymbols = new UnicodeSet("[:Sm:]").freeze();
static final UnicodeSet otherSymbols =
new UnicodeSet("[:ANY:]").removeAll(mathSymbols).removeAll(punctuation).freeze();

public void testSymbols() {
CLDRFile root = CLDRConfig.getInstance().getAnnotationsFactory().make("root", false);
UnicodeMap<String> expectedMap =
new UnicodeMap<String>()
.putAll(punctuation, "Punctuation")
.putAll(mathSymbols, "Math Symbols")
.putAll(otherSymbols, "Other Symbols")
.freeze();
Set<String> nonEmojiPages = expectedMap.values();
UnicodeMap<Pair<String, String>> failures = new UnicodeMap<>();
PathHeader.Factory phf = PathHeader.getFactory();
for (String path : root) {
XPathParts parts = XPathParts.getFrozenInstance(path);
String cp = parts.getAttributeValue(-1, "cp");
if (cp == null) {
continue; // non-annotation line
}
PathHeader ph = phf.fromPath(path);
PathHeader.SectionId sectionId = ph.getSectionId();
assertEquals("Section for " + cp, PathHeader.SectionId.Characters, sectionId);
PageId pageId = ph.getPageId();
final String actual = pageId.toString();

// collect all the failures rather than having a long list of errors

if (allRgiNoES.contains(cp)) { // check emoji
if (nonEmojiPages.contains(actual)) {
failures.put(cp, Pair.of("«Emoji-Page»", actual));
} else if (actual.equals("Symbols2")) {
failures.put(cp, Pair.of("Emoji Symbols", actual));
}
} else {
String expected = expectedMap.get(cp);
if (!actual.equals(expected)) {
failures.put(cp, Pair.of(expected, actual));
}
}
}
if (!failures.isEmpty()) {
for (Pair<String, String> value : ImmutableSortedSet.copyOf(failures.values())) {
UnicodeSet uset = failures.getSet(value);
errln(

Check failure on line 672 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestAnnotations.java

View workflow job for this annotation

GitHub Actions / build

(TestAnnotations.java:672) Error: Mismatch in 4 cases: expected=Math Symbols actual=Emoji Symbols

Check failure on line 672 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestAnnotations.java

View workflow job for this annotation

GitHub Actions / build

(TestAnnotations.java:672) Error: Mismatch in 103 cases: expected=Math Symbols actual=Other Symbols

Check failure on line 672 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestAnnotations.java

View workflow job for this annotation

GitHub Actions / build

(TestAnnotations.java:672) Error: Mismatch in 2 cases: expected=Other Symbols actual=Emoji Symbols

Check failure on line 672 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestAnnotations.java

View workflow job for this annotation

GitHub Actions / build

(TestAnnotations.java:672) Error: Mismatch in 21 cases: expected=Other Symbols actual=Math Symbols

Check failure on line 672 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestAnnotations.java

View workflow job for this annotation

GitHub Actions / build

(TestAnnotations.java:672) Error: Mismatch in 68 cases: expected=Punctuation actual=Math Symbols

Check failure on line 672 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestAnnotations.java

View workflow job for this annotation

GitHub Actions / build

(TestAnnotations.java:672) Error: Mismatch in 4 cases: expected=Punctuation actual=Other Symbols

Check failure on line 672 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestAnnotations.java

View workflow job for this annotation

GitHub Actions / build

(TestAnnotations.java:672) Error: Mismatch in 15 cases: expected=«Emoji-Page» actual=Math Symbols

Check failure on line 672 in tools/cldr-code/src/test/java/org/unicode/cldr/unittest/TestAnnotations.java

View workflow job for this annotation

GitHub Actions / build

(TestAnnotations.java:672) Error: Mismatch in 94 cases: expected=«Emoji-Page» actual=Other Symbols
"Mismatch in "
+ uset.size()
+ " cases: expected="
+ value.getFirst()
+ " actual="
+ value.getSecond()
+ "\n"
+ uset.toPattern(false));
}
}
}
}

0 comments on commit 801cedc

Please sign in to comment.