Skip to content

Instantly share code, notes, and snippets.

@kil9
Created November 5, 2020 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kil9/f31d200fb3b8195a6e7339114ea61f7c to your computer and use it in GitHub Desktop.
Save kil9/f31d200fb3b8195a6e7339114ea61f7c to your computer and use it in GitHub Desktop.
#!/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)
@kil9
Copy link
Author

kil9 commented Nov 5, 2020

❯ python3 translate.py
A: なにかし こち こい そちか たいくわんに いて みか 申

A: nanikasi kochi koi sochika taikuwangni ite mika su

D: 나닝가시 고찌 고이 소찡가 다이관니 이뗴 밍가모우수

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment