Exemplo n.º 1
0
def tohepburn(namestr):
  namestr = kakasi.wakachi(namestr)
  names = kakasi.hepburn(namestr)
  names = names.replace(u"^", u"_").replace(u" ", u"_")
  names = names.replace(u"_,", u",").replace(u",_", u",")
  names = names.replace(u"___", u"_")
  return names
Exemplo n.º 2
0
def translate(dictionary, names):
  kana = kakasi.wakachi(names)
  romaji = kakasi.hepburn(kana).replace(u" ", u"_").replace(u"^", "_")

  nameArray = names.split(u",")
  romajiArray = romaji.replace(u"_,", u",").replace(u",_", u",").split(u",")

  for i in range(len(nameArray)):
    dictionary.writerow([nameArray[i].encode('sjis'), romajiArray[i].encode('sjis')])