UniTO/tesi/conv.py

22 lines
579 B
Python
Raw Normal View History

2020-02-21 19:13:13 +01:00
import json
from sys import argv
allsymbols = json.load(open('./unicode-latex.json'))
symbols = ['', '', '', '', '', '', '', '', '', '', '', '', '' ]
symbols = {s: allsymbols[s] for s in symbols}
print(symbols)
def read_by_char(fname):
with open(fname, 'r') as fp:
for line in fp.readlines():
for ch in line:
yield ch
def convert(ch):
return symbols[ch] if ch in symbols else ch
newfile = [convert(ch) for ch in read_by_char(argv[1])]
with open(argv[2], 'w') as f:
f.writelines(newfile)