Skip to content

One symbol table to rule them all #1080

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 38 commits into from
Apr 2, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
a60805c
aaaaa
eggrobin Mar 25, 2025
cebd1b5
meow
eggrobin Mar 25, 2025
d79bdff
wrap
eggrobin Mar 25, 2025
186afad
fallback
eggrobin Mar 26, 2025
da5eb68
meow
eggrobin Mar 26, 2025
9ee1c94
Identity and null queries
eggrobin Mar 26, 2025
92b3be1
comparison
eggrobin Mar 27, 2025
4a8998a
Factor things out and write the other path
eggrobin Mar 27, 2025
0c30361
eggrobin Mar 27, 2025
830399b
A test
eggrobin Mar 28, 2025
4817cae
The first test that passes
eggrobin Mar 28, 2025
9fcab45
Basic debugging
eggrobin Mar 28, 2025
7048be3
Intro tests
eggrobin Mar 28, 2025
75e4250
More tests, more bugs
eggrobin Mar 28, 2025
73fd0d0
More examples
eggrobin Mar 28, 2025
aae8ef8
More tests!
eggrobin Mar 28, 2025
52e273c
More tests!
eggrobin Mar 28, 2025
4ea9a5c
Notice
eggrobin Mar 29, 2025
f00fa5f
More tests, bugfix in RATIONAL_COMPARATOR
eggrobin Mar 31, 2025
3cc1272
Test regular expression queries
eggrobin Mar 31, 2025
1acb083
a bug
eggrobin Mar 31, 2025
60ea2d3
A setter
eggrobin Mar 31, 2025
40677ee
Fix NaN comparison and thereby MakeUnicodeFiles
eggrobin Apr 1, 2025
21d7218
spots
eggrobin Apr 1, 2025
3ce4d2b
comments about strings
eggrobin Apr 1, 2025
b0da269
Set.of
eggrobin Apr 1, 2025
63a5d9f
length() == 0 to isEmpty() passim
eggrobin Apr 1, 2025
6d72490
Giant conditional
eggrobin Apr 1, 2025
bb56f44
Needless else
eggrobin Apr 1, 2025
f8e7e4c
Split function
eggrobin Apr 1, 2025
a227b01
code motion
eggrobin Apr 1, 2025
e205fa4
Redundant else
eggrobin Apr 1, 2025
c6c00b4
Better error messages
eggrobin Apr 1, 2025
710aedb
Sonst null.
eggrobin Apr 1, 2025
a9666e5
Don’t mutate the expected set
eggrobin Apr 1, 2025
04c6f21
Don’t break other tests even if they are doing evil things
eggrobin Apr 1, 2025
27c490f
spot
eggrobin Apr 1, 2025
ae22201
Some more review comments
eggrobin Apr 1, 2025
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
50 changes: 39 additions & 11 deletions unicodetools/src/main/java/org/unicode/props/UnicodeProperty.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import java.util.TreeMap;
import java.util.function.Predicate;
import java.util.regex.Pattern;
import org.unicode.cldr.util.Rational.RationalParser;
import org.unicode.cldr.util.props.UnicodeLabel;

public abstract class UnicodeProperty extends UnicodeLabel {
Expand Down Expand Up @@ -198,6 +199,7 @@ public UnicodeProperty setDelimiter(String value) {
EXTENDED_MASK = 1,
CORE_MASK = ~EXTENDED_MASK,
BINARY_MASK = (1 << BINARY) | (1 << EXTENDED_BINARY),
NUMERIC_MASK = (1 << NUMERIC) | (1 << EXTENDED_NUMERIC),
STRING_MASK = (1 << STRING) | (1 << EXTENDED_STRING),
STRING_OR_MISC_MASK =
(1 << STRING) | (1 << EXTENDED_STRING) | (1 << MISC) | (1 << EXTENDED_MISC),
Expand Down Expand Up @@ -443,19 +445,25 @@ public final UnicodeSet getSet(String propertyValue, UnicodeSet result) {
if (isMultivalued && propertyValue != null && propertyValue.contains(delimiter)) {
throw new IllegalArgumentException(
"Multivalued property values can't contain the delimiter.");
}
if (propertyValue == null) {
return getSet(NULL_MATCHER, result);
}
Comparator<String> comparator;
if (isType(NUMERIC_MASK)) {
// UAX44-LM1.
comparator = RATIONAL_COMPARATOR;
} else if (getName().equals("Name") || getName().equals("Name_Alias")) {
// UAX44-LM2.
comparator = CHARACTER_NAME_COMPARATOR;
} else if (isType(BINARY_OR_ENUMERATED_OR_CATALOG_MASK)) {
// UAX44-LM3
comparator = PROPERTY_COMPARATOR;
} else {
return getSet(
propertyValue == null
? NULL_MATCHER
: new SimpleMatcher(
propertyValue,
getName().equals("Name") || getName().equals("Name_Alias")
? CHARACTER_NAME_COMPARATOR
: isType(STRING_OR_MISC_MASK)
? null
: PROPERTY_COMPARATOR),
result);
// String-valued or Miscellaneous property.
comparator = null;
}
return getSet(new SimpleMatcher(propertyValue, comparator), result);
}

private UnicodeMap<String> unicodeMap = null;
Expand Down Expand Up @@ -725,6 +733,26 @@ public static String toSkeleton(String source) {
return skeletonBuffer.toString();
}

public static final Comparator<String> RATIONAL_COMPARATOR =
new Comparator<String>() {
@Override
public int compare(String x, String y) {
return compareRationals(x, y);
}
};

public static int compareRationals(String a, String b) {
if (a == b) return 0;
if (a == null) return -1;
if (b == null) return 1;
final boolean aIsNaN = equalNames(a, "NaN");
final boolean bIsNaN = equalNames(b, "NaN");
if (aIsNaN && bIsNaN) return 0;
if (aIsNaN) return -1;
if (bIsNaN) return 1;
return RationalParser.BASIC.parse(a).compareTo(RationalParser.BASIC.parse(b));
}

public static final Comparator<String> CHARACTER_NAME_COMPARATOR =
new Comparator<String>() {
@Override
Expand Down
Loading
Loading