-
Notifications
You must be signed in to change notification settings - Fork 0
/
gaps.py
42 lines (37 loc) · 1.58 KB
/
gaps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import json
from collections import Counter
blocks = json.load(open("blocks.json"))
incomplete = [x for x in blocks if x["coverage"] != "all"]
by_age = Counter()
total_gaps = 0
print("By block:")
for i in incomplete:
this_block = json.load(open("blocks/block-%03i.json" % i["ix"]))
missing = {k: v for k, v in this_block["cps"].items() if "fonts" not in v}
mini_by_age = Counter()
for cp, info in missing.items():
age = info.get("age", this_block.get("age"))
name = info.get("name")
by_age[age] += 1
mini_by_age[age] += 1
if (name and "CJK" not in name) and "CJK" not in this_block["name"]:
total_gaps += 1
if len(mini_by_age) == 1:
print(" %s (%s): %i" % (i["name"], age, len(missing)))
else:
sorted_by_age = sorted(list(mini_by_age.keys()), key=lambda x: float(x))
ages = ", ".join("%s: %i" % (age, mini_by_age[age]) for age in sorted_by_age)
print(" %s: %i (%s)" % (i["name"], len(missing), ages))
if len(missing) < 200 and this_block["coverage"] != "none":
for cp, info in missing.items():
name = info.get("name")
age = info.get("age", this_block.get("age"))
if name and "CJK" not in name:
if len(mini_by_age) > 1:
print(" U+%04X: %s (%s)" % (int(cp), name, age))
else:
print(" U+%04X: %s" % (int(cp), name))
print("\nBy age:")
for age in sorted(list(by_age.keys()), key=lambda x: float(x)):
print(" %s: %i" % (age, by_age[age]))
print("\nTotal gaps: %i" % total_gaps)