Skip to content
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

CLDR-16372 Code to replace lateral inheritance markers in trunk #3275

Merged
merged 2 commits into from
Sep 26, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
// import org.unicode.cldr.util.Log;
import org.unicode.cldr.util.SupplementalDataInfo.PluralInfo;
import org.unicode.cldr.util.SupplementalDataInfo.PluralInfo.Count;
import org.unicode.cldr.util.VoteResolver;
import org.unicode.cldr.util.XMLSource;
import org.unicode.cldr.util.XPathParts;
import org.unicode.cldr.util.XPathParts.Comments;
Expand Down Expand Up @@ -2876,11 +2877,11 @@ public void handleEnd() {

@Override
public void handleStart() {
// skip if the locale id's parent isn't root. That is, it must be at level-1
// locale.
// skip if the locale is root.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment wasn't accurate -- this just changes the comment to match the code

skip = getLocaleID().equals(XMLSource.ROOT_ID);
if (!skip) {
parentId = LocaleIDParser.getParent(getLocaleID());
// This locale is "L1" (level one) if its parent is root.
isL1 = parentId.equals(XMLSource.ROOT_ID);
parentFile = null; // lazy evaluate
}
Expand Down Expand Up @@ -2931,14 +2932,19 @@ public void handlePath(String xpath) {
parentFile = factory.make(parentId, true);
}
String parentValue = parentFile.getStringValueWithBailey(xpath);
if (!parentValue.equals(baileyValue)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there was NPE for parentValue null here

harden = true;
if (!baileyValue.equals(parentValue)) {
harden = true; // true if parentValue == null, see comment below
}
message2 = "; L2+";

// Problem case: the parent value is null (not inheritance marker)
// but the child value is ^^^.
// See if we need to fix that.
// Currently harden is true if parentValue is null, which, as of
// 2023-09-20, happens here for only two paths, both in locale
// en_AU:
// //ldml/dates/calendars/calendar[@type="islamic"]/dateTimeFormats/availableFormats/dateFormatItem[@id="yMEd"]
// //ldml/dates/calendars/calendar[@type="islamic"]/dateTimeFormats/availableFormats/dateFormatItem[@id="yMd"]
}
if (harden) {
String fullPath = cldrFileToFilter.getFullXPath(xpath);
Expand Down Expand Up @@ -3052,6 +3058,26 @@ public void handlePath(String xpath) {
replace(fullPath, newPath, value, "Upgrade to " + TARGET_STATUS.name());
}
});

fixList.add(
'Z',
"Zero lateral: convert inheritance marker to specific value if inheritance would be lateral/problematic",
new CLDRFilter() {
@Override
public void handlePath(String xpath) {
String value = cldrFileToFilter.getStringValue(xpath);
if (!CldrUtility.INHERITANCE_MARKER.equals(value)) {
return;
}
String newValue =
VoteResolver.reviseInheritanceAsNeeded(xpath, value, getResolved());
if (value.equals(newValue)) {
return;
}
String fullXPath = cldrFileToFilter.getFullXPath(xpath);
replace(fullXPath, fullXPath, newValue);
}
});
Copy link
Member Author

@btangmu btangmu Sep 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new "-fZ" results in more "hardening" than "-fV", mainly, I think, because "-fZ" doesn't distinguish between level one locales and other locales -- and also, because "-fZ" treats constructed values as lateral inheritance, while "-fV" doesn't

This PR re-enables -fV, and newly enables -fZ. One or the other may be useful for revising the production data, comparing the two is instructive.

}

public static String getLast2Dirs(File sourceDir1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2261,8 +2261,18 @@ public static String reviseInheritanceAsNeeded(String path, String value, CLDRFi
String baileyValue = cldrFile.getBaileyValue(path, pathWhereFound, localeWhereFound);
if (baileyValue != null
&& (CldrUtility.INHERITANCE_MARKER.equals(value) || baileyValue.equals(value))) {
// TODO: decide whether to continue treating GlossonymConstructor.PSEUDO_PATH
// (constructed values) as lateral inheritance. This method originally did not
// take constructed values into account, so it implicitly treated constructed
// values as inherited, given that pathWhereFound doesn't equal path.
// This original behavior corresponds to CONSTRUCTED_PSEUDO_PATH_NOT_LATERAL = false.
// Reference: https://unicode-org.atlassian.net/browse/CLDR-16372
final boolean CONSTRUCTED_PSEUDO_PATH_NOT_LATERAL = false;
value =
pathWhereFound.value.equals(path)
(pathWhereFound.value.equals(path)
|| (CONSTRUCTED_PSEUDO_PATH_NOT_LATERAL
&& GlossonymConstructor.PSEUDO_PATH.equals(
pathWhereFound.value)))
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a change without a difference (in behavior). It paves the way for making -fZ (and vote resolution, etc., in general) a bit more similar to -fV by changing false to true

? CldrUtility.INHERITANCE_MARKER
: baileyValue;
}
Expand Down
Loading