Created
November 5, 2020 15:20
-
-
Save kil9/f31d200fb3b8195a6e7339114ea61f7c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
trans_dict = { | |
'な': 'na', | |
'に': 'ni', | |
'か': 'ka', | |
'し': 'si', | |
'こ': 'ko', | |
'ち': 'chi', | |
'い': 'i', | |
'そ': 'so', | |
'た': 'ta', | |
'く': 'ku', | |
'わ': 'wa', | |
'ん': 'ng', | |
'に': 'ni', | |
'て': 'te', | |
'み': 'mi', | |
'申': 'su', | |
} | |
with open('input.txt') as input, open('output.txt', 'w') as output: | |
for line in input.readlines(): | |
translated = False | |
outline = '' | |
for c in line: | |
if c in trans_dict: | |
outline += trans_dict[c] | |
translated = True | |
else: | |
outline += c | |
output.write(line) | |
if translated: | |
output.write(outline) | |
with open('output.txt') as output: | |
for line in output.readlines(): | |
print(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
❯ python3 translate.py
A: なにかし こち こい そちか たいくわんに いて みか 申
A: nanikasi kochi koi sochika taikuwangni ite mika su
D: 나닝가시 고찌 고이 소찡가 다이관니 이뗴 밍가모우수