Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions UnicodeJsps/src/main/java/org/unicode/jsp/UnicodeSetUtilities.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.ibm.icu.util.ULocale;
import com.ibm.icu.util.VersionInfo;
import java.text.ParsePosition;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -221,15 +222,15 @@ public boolean applyPropertyAlias(
return status;
}

private static String[][] COARSE_GENERAL_CATEGORIES = {
{"Other", "C", "Cc", "Cf", "Cn", "Co", "Cs"},
{"Letter", "L", "Ll", "Lm", "Lo", "Lt", "Lu"},
{"Cased_Letter", "LC", "Ll", "Lt", "Lu"},
{"Mark", "M", "Mc", "Me", "Mn"},
{"Number", "N", "Nd", "Nl", "No"},
{"Punctuation", "P", "Pc", "Pd", "Pe", "Pf", "Pi", "Po", "Ps"},
{"Symbol", "S", "Sc", "Sk", "Sm", "So"},
{"Separator", "Z", "Zl", "Zp", "Zs"},
private static String[][][] COARSE_GENERAL_CATEGORIES = {
{{"Other", "C"}, {"Cc", "Cf", "Cn", "Co", "Cs"}},
{{"Letter", "L"}, {"Ll", "Lm", "Lo", "Lt", "Lu"}},
{{"Cased_Letter", "LC"}, {"Ll", "Lt", "Lu"}},
{{"Mark", "M", "Combining_Mark"}, {"Mc", "Me", "Mn"}},
{{"Number", "N"}, {"Nd", "Nl", "No"}},
{{"Punctuation", "P"}, {"Pc", "Pd", "Pe", "Pf", "Pi", "Po", "Ps"}},
{{"Symbol", "S"}, {"Sc", "Sk", "Sm", "So"}},
{{"Separator", "Z"}, {"Zl", "Zp", "Zs"}},
};

// TODO(eggrobin): I think this function only ever returns true; might as well make it void.
Expand Down Expand Up @@ -304,13 +305,15 @@ private boolean applyPropertyAlias0(
UnicodePropertySymbolTable::parseVersionInfoOrMax));
} else {
if (prop.getName().equals("General_Category")) {
for (String[] coarseValue : COARSE_GENERAL_CATEGORIES) {
final String longName = coarseValue[0];
final String shortName = coarseValue[1];
if (UnicodeProperty.equalNames(propertyValue, longName)
|| UnicodeProperty.equalNames(propertyValue, shortName)) {
for (int i = 2; i < coarseValue.length; ++i) {
prop.getSet(coarseValue[i], result);
for (String[][] coarseValue : COARSE_GENERAL_CATEGORIES) {
final String[] aliases = coarseValue[0];
if (Arrays.stream(aliases)
.anyMatch(
a ->
UnicodeProperty.equalNames(
propertyValue, a))) {
for (var value : coarseValue[1]) {
prop.getSet(value, result);
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,19 @@ public void TestPretty() {
}

@Test
public void TestGeneralCategoryGroupings() {
public void TestGeneralCategoryGroupingsWithIncrementalProperties() {
IndexUnicodeProperties.useIncrementalProperties();
UcdLoader.setOldestLoadedUcd(VersionInfo.UNICODE_10_0);
checkSetsEqual("[\\p{U10:Lu}\\p{U10:Ll}\\p{U10:Lm}\\p{U10:Lt}\\p{U10:Lo}]", "\\p{U10:L}");
UcdLoader.setOldestLoadedUcd(Settings.LAST_VERSION_INFO);
}

@Test
public void TestGeneralCategoryGroupings() {
checkSetsEqual("[\\p{Lu}\\p{Ll}\\p{Lm}\\p{Lt}\\p{Lo}]", "\\p{L}");
checkSetsEqual("[\\p{Mc}\\p{Me}\\p{Mn}]", "\\p{gc=Combining_Mark}");
}

// public void TestAExemplars() {
// checkProperties("[:exemplars_en:]", "[a]", "[\u0350]");
// }
Expand Down
Loading