99import java .util .Map ;
1010import java .util .Set ;
1111import java .util .TreeMap ;
12+ import java .util .TreeSet ;
1213import java .util .stream .Collectors ;
1314import java .util .stream .Stream ;
1415import org .unicode .cldr .util .CLDRFile ;
@@ -46,7 +47,8 @@ static ChangeType getDiff(String current, String last) {
4647 public static void main (String [] args ) throws IOException {
4748 System .out .println (CldrVersion .LAST_RELEASE_EACH_YEAR );
4849
49- System .out .println ("Version\t Year\t " + Joiners .TAB .join (ChangeType .values ()));
50+ System .out .println (Changes .header ());
51+
5052 CldrVersion nextVersion = null ;
5153 for (CldrVersion previousVersion : CldrVersion .LAST_RELEASE_EACH_YEAR ) {
5254 if (nextVersion != null ) {
@@ -56,6 +58,33 @@ public static void main(String[] args) throws IOException {
5658 }
5759 }
5860
61+ private static class Changes {
62+ Counter <ChangeType > changeTypes = new Counter <>();
63+ Set <String > locales = new TreeSet <>();
64+ Counter <DtdType > dtdTypes = new Counter <>();
65+
66+ static String header () {
67+ return Joiners .TAB .join (
68+ "Version" ,
69+ "Year" ,
70+ Joiners .TAB .join (ChangeType .values ()),
71+ "Locales" ,
72+ Joiners .TAB .join (DtdType .values ()));
73+ }
74+
75+ @ Override
76+ public String toString () {
77+ return Joiners .TAB .join (
78+ List .of (ChangeType .values ()).stream ()
79+ .map (x -> String .valueOf (changeTypes .get (x )))
80+ .collect (Collectors .joining ("\t " )),
81+ locales .size (),
82+ List .of (DtdType .values ()).stream ()
83+ .map (x -> String .valueOf (dtdTypes .get (x )))
84+ .collect (Collectors .joining ("\t " )));
85+ }
86+ }
87+
5988 static final Set <String > SKIP_COMMON_SUBDIRS =
6089 Set .of (
6190 "collation" ,
@@ -75,7 +104,8 @@ private static void compare(CldrVersion nextVersion, CldrVersion previousVersion
75104 int commonIndex = release .getNameCount ();
76105 Map <Path , String > failures = new TreeMap <>();
77106
78- Counter <ChangeType > changes = new Counter <>();
107+ Changes changes = new Changes ();
108+
79109 try (Stream <Path > stream =
80110 Files .walk (release ).collect (Collectors .toList ()).parallelStream ()) {
81111 stream .filter (
@@ -95,14 +125,10 @@ private static void compare(CldrVersion nextVersion, CldrVersion previousVersion
95125 }
96126 });
97127 }
98- System .out .println (
99- nextVersion
100- + "\t "
101- + nextVersion .getYear ()
102- + "\t "
103- + List .of (ChangeType .values ()).stream ()
104- .map (x -> String .valueOf (changes .get (x )))
105- .collect (Collectors .joining ("\t " )));
128+ System .out .println (Joiners .TAB .join (nextVersion , nextVersion .getYear (), changes ));
129+ if (nextVersion == CldrVersion .LAST_RELEASE_EACH_YEAR .get (0 )) {
130+ System .out .println (changes .locales );
131+ }
106132 if (!failures .isEmpty ()) {
107133 System .out .println (failures );
108134 }
@@ -113,7 +139,7 @@ private static Path replaceBase(Path x, Path xPrefix, Path otherPrefix) {
113139 return otherPrefix .resolve (relativePath );
114140 }
115141
116- private static String getChanges (Counter < ChangeType > changes , Path x , Path previousRelease ) {
142+ private static String getChanges (Changes changes , Path x , Path previousRelease ) {
117143 CLDRFile current = null ;
118144 CLDRFile last = null ;
119145 try {
@@ -130,26 +156,31 @@ private static String getChanges(Counter<ChangeType> changes, Path x, Path previ
130156 } catch (Exception e ) {
131157 return e .getMessage ();
132158 }
133- boolean mayHaveValueAttributes = current .getDtdType () != DtdType .ldml ;
159+ boolean isLdml = current .getDtdType () == DtdType .ldml ;
160+ if (isLdml ) {
161+ changes .locales .add (x .getFileName ().toString ());
162+ }
163+ boolean mayHaveValueAttributes = !isLdml ;
134164 DtdData dtdData = current .getDtdData ();
135165 // could optimize by finding elements with value attributes and caching
136166 for (String currentPath : current ) {
167+ changes .dtdTypes .add (dtdData .dtdType , 1 );
137168 String currentValue = current .getStringValue (currentPath );
138169 String lastValue = last == null ? null : last .getStringValue (currentPath );
139170 if (currentPath .contains ("/annotations/" )) {
140171 Set <String > currentSet = getVBarSet (currentValue );
141172 Set <String > lastSet = getVBarSet (lastValue );
142173 int sameCount = Sets .intersection (currentSet , lastSet ).size ();
143- changes .add (ChangeType .same , sameCount );
174+ changes .changeTypes . add (ChangeType .same , sameCount );
144175 int addCount = currentSet .size () - sameCount ;
145176 int deleteCount = lastSet .size () - sameCount ;
146177 int changeCount = Math .min (addCount , deleteCount );
147- changes .add (ChangeType .changed , addCount );
148- changes .add (ChangeType .added , addCount - changeCount );
149- changes .add (ChangeType .deleted , deleteCount - changeCount );
178+ changes .changeTypes . add (ChangeType .changed , addCount );
179+ changes .changeTypes . add (ChangeType .added , addCount - changeCount );
180+ changes .changeTypes . add (ChangeType .deleted , deleteCount - changeCount );
150181 } else {
151182 ChangeType changeType = ChangeType .getDiff (currentValue , lastValue );
152- changes .add (changeType , 1 );
183+ changes .changeTypes . add (changeType , 1 );
153184 }
154185 if (mayHaveValueAttributes ) {
155186 XPathParts currentParts =
@@ -170,7 +201,7 @@ private static String getChanges(Counter<ChangeType> changes, Path x, Path previ
170201 && attributeInfo .attributeStatus == AttributeStatus .value ) {
171202 String currentAttributeValue = currentAttributes .get (attribute );
172203 String lastAttributeValue = lastAttributes .get (attribute );
173- changes .add (
204+ changes .changeTypes . add (
174205 ChangeType .getDiff (currentAttributeValue , lastAttributeValue ),
175206 1 );
176207 }
0 commit comments