CheckAll.java 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. import com.grack.nanojson.JsonObject;
  2. import com.grack.nanojson.JsonParser;
  3. import java.io.File;
  4. import java.io.FileInputStream;
  5. import java.util.Arrays;
  6. import java.util.Map;
  7. public class CheckAll {
  8. public static void main(String[] args) throws Exception {
  9. int SECONDS = 59, currentSeconds = 0;
  10. int MINUTES = 59, currentMinutes = 0;
  11. int HOURS = 23, currentHours = 0;
  12. int DAYS = 6, currentDays = 0;
  13. int WEEKS = 4, currentWeeks = 0;
  14. int MONTHS = 11, currentMonths = 0;
  15. int YEARS = 12, currentYears = 0;
  16. for (String name : Arrays.asList("seconds", "minutes", "hours", "days", "weeks", "months", "years")) {
  17. JsonObject object = JsonParser.object().from(new FileInputStream(new File("timeago-parser/raw/times/" + name + ".json")));
  18. for (Map.Entry<String, Object> entry : object.entrySet()) {
  19. JsonObject value = (JsonObject) entry.getValue();
  20. final int size = value.keySet().size();
  21. if (size >= 80) {
  22. if (name.equals("seconds")) currentSeconds++;
  23. if (name.equals("minutes")) currentMinutes++;
  24. if (name.equals("hours")) currentHours++;
  25. if (name.equals("days")) currentDays++;
  26. if (name.equals("weeks")) currentWeeks++;
  27. if (name.equals("months")) currentMonths++;
  28. if (name.equals("years")) currentYears++;
  29. } else {
  30. System.err.println("Missing some units in: " + name + " → " + entry.getKey() + " (current size = " + size + ")");
  31. }
  32. String number = entry.getKey().replaceAll("\\D", "");
  33. for (Map.Entry<String, Object> langsKeys : value.entrySet()) {
  34. String lang = langsKeys.getKey();
  35. String langValue = String.valueOf(langsKeys.getValue());
  36. String langValueNumber = langValue.replaceAll("\\D", "");
  37. if (!langValueNumber.equals(number)) {
  38. final String msg = langValueNumber.isEmpty() ? "doesn't contain number" : "different number";
  39. System.out.printf("%-20s[!] %22s: %10s = %s \n", entry.getKey(), msg, lang, langValue);
  40. }
  41. }
  42. }
  43. }
  44. System.out.println("\n\nHow many:\n");
  45. if (currentSeconds == SECONDS) System.out.println("seconds: " + currentSeconds);
  46. else System.out.println("[!] missing seconds: " + currentSeconds);
  47. if (currentMinutes == MINUTES) System.out.println("minutes: " + currentMinutes);
  48. else System.out.println("[!] missing minutes: " + currentMinutes);
  49. if (currentHours == HOURS) System.out.println("hours: " + currentHours);
  50. else System.out.println("[!] missing hours: " + currentHours);
  51. if (currentDays == DAYS) System.out.println("days: " + currentDays);
  52. else System.out.println("[!] missing days: " + currentDays);
  53. if (currentWeeks == WEEKS) System.out.println("weeks: " + currentWeeks);
  54. else System.out.println("[!] missing weeks: " + currentWeeks);
  55. if (currentMonths == MONTHS) System.out.println("months: " + currentMonths);
  56. else System.out.println("[!] missing months: " + currentMonths);
  57. if (currentYears == YEARS) System.out.println("years: " + currentYears);
  58. else System.out.println("[!] missing years: " + currentYears);
  59. }
  60. }