aboutsummaryrefslogtreecommitdiffstats
path: root/tools/java/org/unicode/cldr/tool/GetChanges.java
diff options
context:
space:
mode:
Diffstat (limited to 'tools/java/org/unicode/cldr/tool/GetChanges.java')
-rw-r--r--tools/java/org/unicode/cldr/tool/GetChanges.java114
1 files changed, 96 insertions, 18 deletions
diff --git a/tools/java/org/unicode/cldr/tool/GetChanges.java b/tools/java/org/unicode/cldr/tool/GetChanges.java
index bf8f87e..cbf8717 100644
--- a/tools/java/org/unicode/cldr/tool/GetChanges.java
+++ b/tools/java/org/unicode/cldr/tool/GetChanges.java
@@ -1,7 +1,10 @@
package org.unicode.cldr.tool;
+import java.util.Collections;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Objects;
+import java.util.Set;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -11,9 +14,15 @@ import org.unicode.cldr.util.CLDRFile;
import org.unicode.cldr.util.CLDRPaths;
import org.unicode.cldr.util.CldrUtility;
import org.unicode.cldr.util.Factory;
+import org.unicode.cldr.util.LanguageTagParser;
+import org.unicode.cldr.util.Level;
+import org.unicode.cldr.util.Organization;
import org.unicode.cldr.util.PathHeader;
import org.unicode.cldr.util.PatternCache;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Multimap;
+import com.google.common.collect.TreeMultimap;
import com.ibm.icu.util.Output;
public class GetChanges {
@@ -43,9 +52,17 @@ public class GetChanges {
CLDRConfig testInfo = ToolConfig.getToolInstance();
CLDRFile english = testInfo.getEnglish();
- Factory lastReleaseFactory = Factory.make(CLDRPaths.LAST_DIRECTORY + "common/main/", ".*");
- Factory trunkFactory = testInfo.getCldrFactory();
- Factory snapshotFactory = Factory.make(CLDRPaths.TMP2_DIRECTORY + "vxml/common/main/", ".*");
+ boolean onlyMissing = true;
+ String release = "33.1";
+
+ String subdir = "annotations"; // "main";
+ Factory lastReleaseFactory = Factory.make(CLDRPaths.LAST_DIRECTORY + "common/"
+ + subdir, ".*");
+ Factory trunkFactory = testInfo.getAnnotationsFactory(); // CldrFactory();
+ Factory snapshotFactory = Factory.make(CLDRPaths.AUX_DIRECTORY + "voting/"
+ + release
+ + "/vxml/common/"
+ + subdir, ".*");
PathHeader.Factory phf = PathHeader.getFactory(english);
int totalCount = 0;
@@ -54,33 +71,84 @@ public class GetChanges {
Output<String> localeWhereFound = new Output<String>();
Output<String> pathWhereFound = new Output<String>();
- for (String locale : lastReleaseFactory.getAvailable()) {
+ CLDRFile englishCldrFile = trunkFactory.make("en", false);
+ final Set<String> paths = ImmutableSet.copyOf(englishCldrFile.iterator());
+ System.out.println("english paths: " + paths.size());
+
+ Multimap<String,PathHeader> missing = TreeMultimap.create();
+
+ Set<String> locales = testInfo.getStandardCodes().getLocaleCoverageLocales(Organization.cldr, Collections.singleton(Level.MODERN));
+
+ LanguageTagParser ltp = new LanguageTagParser();
+ for (String locale : locales) {
+ if (!ltp.set(locale).getRegion().isEmpty() || locale.equals("sr_Latn")) {
+ continue; // skip region locales, they'll inherit
+ }
+// if (!locale.equals("sr_Latn")) {
+// continue;
+// }
+ System.out.println(locale);
+
+ CLDRFile snapshot;
+ try {
+ snapshot = snapshotFactory.make(locale, false);
+ } catch (Exception e) {
+ System.out.println("Skipping " + locale + ", no data in annotations/");
+ continue;
+ }
+
+ CLDRFile lastRelease = null;
+ try {
+ lastRelease = lastReleaseFactory.make(locale, false);
+ } catch (Exception e) {
+ }
+
+ CLDRFile trunk = null;
+ try {
+ trunk = trunkFactory.make(locale, false);
+ } catch (Exception e) {
+ }
+
Map<PathHeader, Data> results = new TreeMap<PathHeader, Data>();
- CLDRFile lastRelease = lastReleaseFactory.make(locale, false);
- CLDRFile trunk = trunkFactory.make(locale, false);
- CLDRFile snapshot = snapshotFactory.make(locale, true);
- for (String xpath : lastRelease) {
- if (xpath.contains("fallbackRegionFormat") || xpath.contains("exemplar")) {
+
+ for (String xpath : paths) {
+ if (xpath.contains("fallbackRegionFormat")
+ || xpath.contains("exemplar")
+ || xpath.contains("/identity")) {
continue;
}
- String valueLastRelease = lastRelease.getStringValue(xpath);
String newPath = fixOldPath(xpath);
String valueSnapshot = snapshot.getStringValue(newPath);
- if (valueLastRelease.equals(valueSnapshot)) {
+ PathHeader ph = null;
+
+ if (valueSnapshot == null) {
+ ph = phf.fromPath(newPath);
+ missing.put(locale, ph);
+ }
+ String valueLastRelease = lastRelease == null ? null : lastRelease.getStringValue(xpath);
+ if (valueSnapshot == null) {
+ ph = phf.fromPath(newPath);
+ missing.put(locale, ph);
+ }
+
+ if (onlyMissing) {
continue;
}
- String valueTrunk = trunk.getStringValue(newPath);
- if (valueSnapshot == null && valueTrunk == null) { // committee deletion
+ if (valueSnapshot != null && Objects.equals(valueLastRelease, valueSnapshot)) {
continue;
}
+ String valueTrunk = trunk == null ? null : trunk.getStringValue(newPath);
+// if (valueSnapshot == null && valueTrunk == null) { // committee deletion
+// continue;
+// }
// skip inherited
String baileyValue = snapshot.getConstructedBaileyValue(xpath, pathWhereFound, localeWhereFound);
- if (!localeWhereFound.value.equals("root")
- && !localeWhereFound.value.equals("code-fallback")
+ if (!"root".equals(localeWhereFound.value)
+ && !"code-fallback".equals(localeWhereFound.value)
&& CldrUtility.equals(valueSnapshot, baileyValue)) {
continue;
}
- PathHeader ph = phf.fromPath(newPath);
+ ph = ph != null ? ph : phf.fromPath(newPath);
results.put(ph, new Data(valueLastRelease, valueSnapshot, valueTrunk));
}
if (results.isEmpty()) {
@@ -89,12 +157,22 @@ public class GetChanges {
int itemCount = 0;
localeCount++;
for (Entry<PathHeader, Data> entry : results.entrySet()) {
- System.out.println(localeCount + "\t" + ++itemCount + "\t" + locale + "\t" + english.getName(locale) + "\t«" + entry.getKey() + "\t"
- + entry.getValue());
+ PathHeader ph = entry.getKey();
+ String englishValue = englishCldrFile.getStringValue(ph.getOriginalPath());
+ System.out.println(localeCount
+ + "\t" + ++itemCount
+ + "\t" + locale
+ + "\t" + english.getName(locale)
+ + "\t" + ph
+ + "\t«" + englishValue
+ + "»\t" + entry.getValue());
}
totalCount += itemCount;
}
System.out.println("Total:\t" + totalCount);
+ for ( Entry<String, PathHeader> entry : missing.entries()) {
+ System.out.println(entry.getKey() + "\t" + entry.getValue());
+ }
}
static Pattern OLD_PATH = PatternCache.get("//ldml/units/unit\\[@type=\"([^\"]*)\"]/unitPattern\\[@count=\"([^\"]*)\"](\\[@alt=\"([^\"]*)\"])?");