Skip to content

Instantly share code, notes, and snippets.

@kacchan822
Created July 23, 2016 07:13
Show Gist options
  • Save kacchan822/e7263776254d080ed1042c746449e641 to your computer and use it in GitHub Desktop.
Save kacchan822/e7263776254d080ed1042c746449e641 to your computer and use it in GitHub Desktop.
""" generate kana """
def rubi(letters):
"""Generate kana.
alphabet upper case letter --> 'カタカナ'(大文字)
alphabet lowe case letter --> 'カタカナ'
none alphabet letter --> not convert to kana.
each kana is joined by '・'.
Args:
letters (str): kana alphabet
Returns:
kana stings.
"""
rubi_letters = {
'A':'エイ(大文字)', 'B':'ビー(大文字)', 'C':'シー(大文字)', 'D':'ディー(大文字)',
'E':'イー(大文字)', 'F':'エフ(大文字)', 'G':'ジー(大文字)', 'H':'エイチ(大文字)',
'I':'アイ(大文字)', 'J':'ジェイ(大文字)', 'K':'ケイ(大文字)', 'L':'エル(大文字)',
'M':'エム(大文字)', 'N':'エヌ(大文字)', 'O':'オー(大文字)', 'P':'ピー(大文字)',
'Q':'キュー(大文字)', 'R':'アール(大文字)', 'S':'エス(大文字)', 'T':'ティー(大文字)',
'U':'ユー(大文字)', 'V':'ヴィー(大文字)', 'W':'ダブリュー(大文字)', 'X':'エックス(大文字)',
'Y':'ワイ(大文字)', 'Z':'ゼット(大文字)',
'a':'エイ', 'b':'ビー', 'c':'シー', 'd':'ディー', 'e':'イー', 'f':'エフ', 'g':'ジー',
'h':'エイチ', 'i':'アイ', 'j':'ジェイ', 'k':'ケイ', 'l':'エル', 'm':'エム', 'n':'エヌ',
'o':'オー', 'p':'ピー', 'q':'キュー', 'r':'アール', 's':'エス', 't':'ティー', 'u':'ユー',
'v':'ヴィー', 'w':'ダブリュー','x':'エックス', 'y':'ワイ', 'z':'ゼット',
}
rubi = ''
for i in list(letters):
if i in rubi_letters.keys():
rubi += rubi_letters[i]
else:
rubi += i
rubi += '・'
return rubi[:-1]
if __name__ == '__main__':
import sys
try:
print(rubi(sys.argv[1]))
except:
print("give one argument(string) that you want to generate kana")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment