Skip to content

Commit

Permalink
Merge remote-tracking branch 'jdufresne/tools-py3'
Browse files Browse the repository at this point in the history
  • Loading branch information
avian2 committed Jan 19, 2019
2 parents 74e552a + 6d79aa1 commit 1533d58
Showing 1 changed file with 25 additions and 23 deletions.
48 changes: 25 additions & 23 deletions tools/check_character_names.py
Original file line number Diff line number Diff line change
@@ -1,33 +1,35 @@
import sys
import re
import unidecode

all = 0
name_re = re.compile("LATIN (SMALL|CAPITAL) LETTER (?:.* )?([A-Z])(?: .*)?$")

total = 0
good = 0
for line in open("NamesList.txt"):
f = line.split('\t')
try:
cp = int(f[0], 16)
except ValueError:
continue
name = f[1]
with open("NamesList.txt") as fp:
for line in fp:
f = line.split('\t')
try:
cp = int(f[0], 16)
except ValueError:
continue
name = f[1]

g = re.search("LATIN (SMALL|CAPITAL) LETTER (?:.* )?([A-Z])(?: .*)?$", name)
if g:
cap = g.group(1)
letter = g.group(2)
g = name_re.search(name)
if g:
cap = g.group(1)
letter = g.group(2)

if cap == 'SMALL':
letter = letter.lower()
if cap == 'SMALL':
letter = letter.lower()

char = unichr(cp)
letteru = unidecode.unidecode(char)
char = chr(cp)
letteru = unidecode.unidecode(char)

if letteru != letter:
print letteru, letter, char, "%05x" % cp, name.strip()
else:
good += 1
if letteru != letter:
print(letteru, letter, char, "%05x" % cp, name.strip())
else:
good += 1

all += 1
total += 1

print 100.0*good/all
print(100.0 * good / total)

0 comments on commit 1533d58

Please sign in to comment.