# encoding: utf-8
 
#reating dictionary
#if 0 - quit
#if terminput - trnslate
#you can reaasign value to a key
#you can add new key
#you can delete key
 
print '''
いらっしやい!
0 - Exit
1 - Enter your English word to get Japanese equivalent
2 - Enter your Japanese word to get English equivalent
3 - Add new Japanese word to dictionary and set it's <both ways> translation
4 - Add English word to dictionary and set it's <both ways> translation
5 - Delete words from dictionary
6 - Play game
'''
dictEnAlph = {'so':'そ', 'wo':'を', 'no':'の', 'to':'と', 'ko':'こ', 'ro':'ろ', 'ho':'ほ', 'mo':'も', 'yo':'よ', 'o':'お', 'a':'あ', 'ka':'か', 'ta':'た', 'sa':'さ', 'ma':'ま', 'na':'な', 'ha':'は', 'ya':'や', 'wa':'わ', 'ra':'ら', 'n':'ん', 'e':'え', 'ke':'け', 'se':'せ', 'te':'て', 'ne':'ね', 're':'れ', 'he':'へ', 'me':'め', 'i':'い', 'ki':'き', 'hi':'ひ', 'ni':'に', 'mi':'み', 'shi':'し', 'chi':'ち', 'ri':'リ', 'u':'う', 'nu':'ぬ', 'ku':'く', 'fu':'ふ', 'tsu':'つ', 'yu':'ゆ', 'mu':'む', 'su':'す', 'ru':'る', 'we':'ゑ', 'wi':'ゐ'}
dictJpAlph = {v: k for k, v in dictEnAlph.items()}
dictEnWrd = {'picture':'え', 'house':('いえ', 'うち'), 'yes':'ええ', 'no':'いいえ', 'metal bucket':'かこ', 'kid':'こ', 'voice':'こえ', 'english':'えいご', 'movie':'えいか゜', 'tree':'き', 'student':'がくせい', 'university':'だいがく', 'mister':'かた', 'engineer':'ぎし', 'chair':'いす', 'when':'いつ', 'such':'そう', 'how':'どう', 'please':'どうぞ', 'table':'つくえ', 'house':'うち', 'morning':'あさ', 'man':'ひと', 'you (familiar)':'あなた', 'he(mister)':'あなかた', 'he':'あのひと', 'dog':'いぬ', 'wall':'かべ', 'flower':'はな', 'box':'はこ', 'magazine':'ざっし', 'map':'ちず', 'cat':'ねこ', 'brush':'ふど'}
dictJpWrd = {v: k for k, v in dictEnWrd.items()}
import random
t = None
t1 = None
t3 = None
t33 = None
t2 = None
t22 = None
t4 = None
t44 = None
 
#print inv_map
#print len(inv_map)
#list1 = slogodictionary.keys()
#list2 = slogodictionary.values()
#print list1
#for v in list2:
#	print v
#dict2 = {}
#x = 0
#print len(slogodictionary.values())
#while True:
#	if x < len(slogodictionary.values()):
#		term = list2[x]
#		value = list1[x]
#		dict2[term] = value
#		x += 1		
#		print len(dict2)
#		
#	if x == len(slogodictionary.values()):
#		break
#dict2		
while True: 
	if t != 0:
		t = int(raw_input('Enter your choice of action between 0 and 6\n'))
	if t == 1:
		t1 = raw_input('Enter your English word here　to see Japanese translation\n')
		if t1 in dictEnAlph:
			print dictEnAlph[t1]
		elif t1 in dictEnWrd:
			print dictEnWrd[t1]
	if t == 2:
		t3 = raw_input('Enter your Japanese word here to see English translation\n')
		if t3 in dictJpAlph:
			print dictJpAlph[t3]
		elif t3 in dictJpWrd:
			print dictJpWrd[t3]
	if t == 3:
		t2 = raw_input('Enter your Japanese word with Hiragana symbols\n')
		t22 = raw_input('Enter the translation value of this Hiragana word\n')
		if t2 not in dictJpWrd:
			dictJpWrd[t2] = t22
			dictEnWrd[t22] = t2
			print t2, 'and', dictJpWrd, dictEnWrd, 'has been updated!'
	if t == 4:
		t4 = raw_input('Enter your English word')
		t44 = raw_input('Enter its Japanese translation')
		if t4 not in dictEnWrd:
			dictEnWrd[t4] = t44
			dictJpWrd[t44] = t4
	if t == 6:
		#r = random.choice([dictEnWrd.keys()])
		r = random.sample(dictEnWrd, 1)
		n = r[0]
		print 'Try to guess what is the translation of', r, '?\n'
                m = raw_input('Guess\n')
		
                if m == dictEnWrd[n]:
        		print 'Congratulations!'			
		else:
			print 'Fail! Try again'	
print 'さよなら！'
 
 
raw_input('\n\nP')