-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy paththiayaml_ganbun_keyboard.py
42 lines (36 loc) · 1.02 KB
/
thiayaml_ganbun_keyboard.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 regex
from ganbun import input
file1 = open('taigi_pojhanlo.dict.yaml',encoding="utf-8")
Lines = file1.readlines()
count = 0
p = regex.compile(r'\p{Script=Han}+')
# Strips the newline character
with open("test.csv", encoding="utf-8", mode='w') as f:
for line in Lines:
line = line.split('\t')
out = line[0]
if p.fullmatch(out) == None:
result, status = input(out)
if status != False:
line[0] = result
if line[-1] == "0\n":
line[-1] = "\n"
# if len(line[0]) != 2 and len(line[0]) != 3 :
# continue
else:
continue
s = line[1][:-1]+ " " + line[0][:-1] + "\n"
print(s)
f.write(s)
else:
result, status = input(out)
if len(result) == 1:
line[0] = result
if line[-1] == "0\n":
line[-1] = "\n"
else:
continue
s = line[1]+ " " + line[0] + "\n"
print(s)
f.write(s)
# print(line)