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-8956 add tool for missing dtd items in spec #2764

Merged
Show file tree
Hide file tree
Changes from all commits
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 @@ -37,7 +37,9 @@
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.ImmutableSortedSet;
import com.google.common.collect.Multimap;
import com.google.common.collect.Multiset;
import com.google.common.collect.TreeMultimap;
import com.google.common.collect.TreeMultiset;

public class ListCoverageLevels {
public static void main(String[] args) {
Expand All @@ -49,7 +51,7 @@ public static void main(String[] args) {
PathStarrer starrer = new PathStarrer().setSubstitutionPattern("*");
Factory mainAndAnnotationsFactory = config.getMainAndAnnotationsFactory();

Set<String> toTest = sc.getLocaleCoverageLocales(Organization.cldr, EnumSet.allOf(Level.class));
Set<String> toTest = sc.getLocaleCoverageLocales(Organization.cldr, EnumSet.of(Level.MODERN));
// ImmutableSortedSet.of("it", "root", "ja");
// mainAndAnnotationsFactory.getAvailable();
final Set<CLDRLocale> ALL;
Expand All @@ -59,6 +61,29 @@ public static void main(String[] args) {
ALL = ImmutableSet.copyOf(_ALL);
}

Map<Level, Multiset<String>> levelToCounter = new TreeMap<>();
for (Level level : Level.values()) {
levelToCounter.put(level, TreeMultiset.create());
}
for (String locale : toTest) {
CLDRFile file = mainAndAnnotationsFactory.make(locale, false);
CoverageLevel2 coverageLeveler = CoverageLevel2.getInstance(locale);
System.out.println(locale);
for (String path : file) {
Level level = coverageLeveler.getLevel(path);
String skeleton = starrer.set(path);
levelToCounter.get(level).add(skeleton);
}
}
for (Entry<Level, Multiset<String>> entry : levelToCounter.entrySet()) {
Level level = entry.getKey();
Multiset<String> counter = entry.getValue();
for (Multiset.Entry<String> skeleton : counter.entrySet()) {
System.out.println(level + "\t" + skeleton.getCount() + "\t" + skeleton.getElement());
}
}
if (true) return;

M4<Level, String, Attributes, Boolean> data = ChainedMap.of(
new TreeMap<Level,Object>(),
new TreeMap<String,Object>(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,30 @@

import java.io.File;
import java.text.ParseException;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.Deque;
import java.util.EnumMap;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeMap;
import java.util.TreeSet;
import java.util.concurrent.ConcurrentHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -1739,7 +1761,10 @@ private void handleParentLocales(XPathParts parts) {
String locales = parts.getAttributeValue(-1, "locales");
String[] pl = locales.split(" ");
for (int i = 0; i < pl.length; i++) {
parentLocales.put(pl[i], parent);
String old = parentLocales.put(pl[i], parent);
if (old != null) {
throw new IllegalArgumentException("Locale " + pl[i] + " cannot have two parents: " + old + " and " + parent);
}
}
}

Expand Down
Loading