#!/usr/bin/env python
# -*- coding: utf-8 -*-

from . import tools

# the romaji to kana hash table
rtok = {}
rtok["a"] = "あ"
rtok["A"] = "ア"
rtok["i"] = "い"
rtok["I"] = "イ"
rtok["u"] = "う"
rtok["U"] = "ウ"
rtok["e"] = "え"
rtok["E"] = "エ"
rtok["o"] = "お"
rtok["O"] = "オ"
rtok["ka"] = "か"
rtok["KA"] = "カ"
rtok["ki"] = "き"
rtok["KI"] = "キ"
rtok["ku"] = "く"
rtok["KU"] = "ク"
rtok["ke"] = "け"
rtok["KE"] = "ケ"
rtok["ko"] = "こ"
rtok["KO"] = "コ"
rtok["sa"] = "さ"
rtok["SA"] = "サ"
rtok["si"] = "し"
rtok["SI"] = "シ"
rtok["shi"] = "し"
rtok["SHI"] = "シ"
rtok["su"] = "す"
rtok["SU"] = "ス"
rtok["se"] = "せ"
rtok["SE"] = "セ"
rtok["so"] = "そ"
rtok["SO"] = "ソ"
rtok["ta"] = "た"
rtok["TA"] = "タ"
rtok["ti"] = "ち"
rtok["TI"] = "チ"
rtok["chi"] = "ち"
rtok["CHI"] = "チ"
rtok["tu"] = "つ"
rtok["TU"] = "ツ"
rtok["tsu"] = "つ"
rtok["TSU"] = "ツ"
rtok["te"] = "て"
rtok["TE"] = "テ"
rtok["to"] = "と"
rtok["TO"] = "ト"
rtok["na"] = "な"
rtok["NA"] = "ナ"
rtok["ni"] = "に"
rtok["NI"] = "ニ"
rtok["nu"] = "ぬ"
rtok["NU"] = "ヌ"
rtok["ne"] = "ね"
rtok["NE"] = "ネ"
rtok["no"] = "の"
rtok["NO"] = "ノ"
rtok["ha"] = "は"
rtok["HA"] = "ハ"
rtok["hi"] = "ひ"
rtok["HI"] = "ヒ"
rtok["hu"] = "ふ"
rtok["HU"] = "フ"
rtok["fu"] = "ふ"
rtok["FU"] = "フ"
rtok["he"] = "へ"
rtok["HE"] = "ヘ"
rtok["ho"] = "ほ"
rtok["HO"] = "ホ"
rtok["ma"] = "ま"
rtok["MA"] = "マ"
rtok["mi"] = "み"
rtok["MI"] = "ミ"
rtok["mu"] = "む"
rtok["MU"] = "ム"
rtok["me"] = "め"
rtok["ME"] = "メ"
rtok["mo"] = "も"
rtok["MO"] = "モ"
rtok["ya"] = "や"
rtok["YA"] = "ヤ"
rtok["yu"] = "ゆ"
rtok["YU"] = "ユ"
rtok["yo"] = "よ"
rtok["YO"] = "ヨ"
rtok["ra"] = "ら"
rtok["RA"] = "ラ"
rtok["ri"] = "り"
rtok["RI"] = "リ"
rtok["ru"] = "る"
rtok["RU"] = "ル"
rtok["re"] = "れ"
rtok["RE"] = "レ"
rtok["ro"] = "ろ"
rtok["RO"] = "ロ"
rtok["LA"] = "ラ"
rtok["li"] = "り"
rtok["LI"] = "リ"
rtok["lu"] = "る"
rtok["LU"] = "ル"
rtok["le"] = "れ"
rtok["LE"] = "レ"
rtok["lo"] = "ろ"
rtok["LO"] = "ロ"
rtok["wa"] = "わ"
rtok["WA"] = "ワ"
rtok["wo"] = "を"
rtok["WO"] = "ヲ"
rtok["ga"] = "が"
rtok["GA"] = "ガ"
rtok["gi"] = "ぎ"
rtok["GI"] = "ギ"
rtok["gu"] = "ぐ"
rtok["GU"] = "グ"
rtok["ge"] = "げ"
rtok["GE"] = "ゲ"
rtok["go"] = "ご"
rtok["GO"] = "ゴ"
rtok["za"] = "ざ"
rtok["ZA"] = "ザ"
rtok["zi"] = "じ"
rtok["ZI"] = "ジ"
rtok["ji"] = "じ"
rtok["JI"] = "ジ"
rtok["zu"] = "ず"
rtok["ZU"] = "ズ"
rtok["ze"] = "ぜ"
rtok["ZE"] = "ゼ"
rtok["zo"] = "ぞ"
rtok["ZO"] = "ゾ"
rtok["da"] = "だ"
rtok["DA"] = "ダ"
rtok["di"] = "ぢ"
rtok["DI"] = "ヂ"
rtok["du"] = "づ"
rtok["DU"] = "ヅ"
rtok["de"] = "で"
rtok["DE"] = "デ"
rtok["do"] = "ど"
rtok["DO"] = "ド"
rtok["ba"] = "ば"
rtok["BA"] = "バ"
rtok["bi"] = "び"
rtok["BI"] = "ビ"
rtok["bu"] = "ぶ"
rtok["BU"] = "ブ"
rtok["be"] = "べ"
rtok["BE"] = "ベ"
rtok["bo"] = "ぼ"
rtok["BO"] = "ボ"
rtok["pa"] = "ぱ"
rtok["PA"] = "パ"
rtok["pi"] = "ぴ"
rtok["PI"] = "ピ"
rtok["pu"] = "ぷ"
rtok["PU"] = "プ"
rtok["pe"] = "ぺ"
rtok["PE"] = "ペ"
rtok["po"] = "ぽ"
rtok["PO"] = "ポ"
rtok["kya"] = "きゃ"
rtok["KYA"] = "キャ"
rtok["kyu"] = "きゅ"
rtok["KYU"] = "キュ"
rtok["kyo"] = "きょ"
rtok["KYO"] = "キョ"
rtok["sha"] = "しゃ"
rtok["SHA"] = "シャ"
rtok["shu"] = "しゅ"
rtok["SHU"] = "シュ"
rtok["sho"] = "しょ"
rtok["SHO"] = "ショ"
rtok["-"] = "ー"
rtok["."] = "。"
rtok["?"] = "？"
rtok["!"] = "！"
rtok[","] = "、"
rtok["_"] = "　"
rtok["["] = "（"
rtok["]"] = "）"
rtok["~"] = "〜"
rtok["cha"] = "ちゃ"
rtok["CHA"] = "チャ"
rtok["chu"] = "ちゅ"
rtok["CHU"] = "チュ"
rtok["cho"] = "ちょ"
rtok["CHO"] = "チョ"
rtok["nya"] = "にゃ"
rtok["NYA"] = "ニャ"
rtok["nyu"] = "にゅ"
rtok["NYU"] = "ニュ"
rtok["nyo"] = "にょ"
rtok["NYO"] = "ニョ"
rtok["hya"] = "ひゃ"
rtok["HYA"] = "ヒャ"
rtok["hyu"] = "ひゅ"
rtok["HYU"] = "ヒュ"
rtok["hyo"] = "ひょ"
rtok["HYO"] = "ヒョ"
rtok["mya"] = "みゃ"
rtok["MYA"] = "ミャ"
rtok["myu"] = "みゅ"
rtok["MYU"] = "ミュ"
rtok["myo"] = "みょ"
rtok["MYO"] = "ミョ"
rtok["rya"] = "りゃ"
rtok["RYA"] = "リャ"
rtok["ryu"] = "りゅ"
rtok["RYU"] = "リュ"
rtok["ryo"] = "りょ"
rtok["RYO"] = "リョ"
rtok["lya"] = "りゃ"
rtok["LYA"] = "リャ"
rtok["lyu"] = "りゅ"
rtok["LYU"] = "リュ"
rtok["lyo"] = "りょ"
rtok["LYO"] = "リョ"
rtok["gya"] = "ぎゃ"
rtok["GYA"] = "ギャ"
rtok["gyu"] = "ぎゅ"
rtok["GYU"] = "ギュ"
rtok["gyo"] = "ぎょ"
rtok["GYO"] = "ギョ"
rtok["ja"] = "じゃ"
rtok["jya"] = "じゃ"
rtok["JA"] = "ジャ"
rtok["JYA"] = "ジャ"
rtok["ju"] = "じゅ"
rtok["jyu"] = "じゅ"
rtok["JU"] = "ジュ"
rtok["JYU"] = "ジュ"
rtok["jo"] = "じょ"
rtok["jyo"] = "じょ"
rtok["JO"] = "ジョ"
rtok["JYO"] = "ジョ"
rtok["bya"] = "びゃ"
rtok["BYA"] = "ビャ"
rtok["byu"] = "びゅ"
rtok["BYU"] = "ビュ"
rtok["byo"] = "びょ"
rtok["BYO"] = "ビョ"
rtok["pya"] = "ぴゃ"
rtok["PYA"] = "ピャ"
rtok["pyu"] = "ぴゅ"
rtok["PYU"] = "ピュ"
rtok["pyo"] = "ぴょ"
rtok["PYO"] = "ピョ"
rtok["zya"] = "じゃ"
rtok["dya"] = "ぢゃ"
rtok["ZYA"] = "ジャ"
rtok["DYA"] = "ヂャ"
rtok["zyu"] = "じゅ"
rtok["ZYU"] = "ジュ"
rtok["dyu"] = "ぢゅ"
rtok["DYU"] = "ヂュ"
rtok["dyo"] = "ぢょ"
rtok["DYO"] = "ヂョ"
rtok["zyo"] = "じょ"
rtok["ZYO"] = "ジョ"
rtok["n"] = "ん"
rtok["N"] = "ン"
rtok["_tsu_"] = "っ"
rtok["_TSU_"] = "ッ"
rtok["->"] = "「"
rtok["<-"] = "」"
rtok["wi"] = "ゐ"
rtok["WI"] = "ヰ"
  
          




def __appendLists(first, second):
  return first + second

def __getKana(rom):
  try:
      ret = rtok[rom]
  except KeyError:
      #ret = rom
      ret = ""
  return ret
  
# takes a string and returns a list of tile numbers
def romajiToKana(input):
   out = ""
   l = tools.splitRomajiToList(input)
   for x in l:
      out = out + __getKana(x)
   return out
