Last active
November 22, 2018 15:00
-
-
Save ishideo/95794428c4e1b3757d29949c4516f975 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 python | |
# -*- coding: utf-8 -*- | |
import sys | |
def _init(argv): | |
if len(argv) == 1: | |
print('usage: katakana2romaji.py カタカナ') | |
sys.exit(1) | |
def katakana2romaji(txt): | |
from pykakasi import kakasi | |
kakasi = kakasi() | |
kakasi.setMode('K', 'a') | |
kakasi.setMode('r', 'Hepburn') | |
conv = kakasi.getConverter() | |
result = conv.do(txt) | |
print(result) | |
def main(): | |
_init(sys.argv) | |
katakana2romaji(sys.argv[1]) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment