fork download
  1. # encoding: utf-8
  2.  
  3. #reating dictionary
  4. #if 0 - quit
  5. #if terminput - trnslate
  6. #you can reaasign value to a key
  7. #you can add new key
  8. #you can delete key
  9.  
  10. print '''
  11. いらっしやい!
  12. 0 - Exit
  13. 1 - Enter your English word to get Japanese equivalent
  14. 2 - Enter your Japanese word to get English equivalent
  15. 3 - Add new Japanese word to dictionary and set it's <both ways> translation
  16. 4 - Add English word to dictionary and set it's <both ways> translation
  17. 5 - Delete words from dictionary
  18. 6 - Play game
  19. '''
  20. 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':'ゐ'}
  21. dictJpAlph = {v: k for k, v in dictEnAlph.items()}
  22. 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':'ふど'}
  23. dictJpWrd = {v: k for k, v in dictEnWrd.items()}
  24. import random
  25. t = None
  26. t1 = None
  27. t3 = None
  28. t33 = None
  29. t2 = None
  30. t22 = None
  31. t4 = None
  32. t44 = None
  33.  
  34. #print inv_map
  35. #print len(inv_map)
  36. #list1 = slogodictionary.keys()
  37. #list2 = slogodictionary.values()
  38. #print list1
  39. #for v in list2:
  40. # print v
  41. #dict2 = {}
  42. #x = 0
  43. #print len(slogodictionary.values())
  44. #while True:
  45. # if x < len(slogodictionary.values()):
  46. # term = list2[x]
  47. # value = list1[x]
  48. # dict2[term] = value
  49. # x += 1
  50. # print len(dict2)
  51. #
  52. # if x == len(slogodictionary.values()):
  53. # break
  54. #dict2
  55. while True:
  56. if t != 0:
  57. t = int(raw_input('Enter your choice of action between 0 and 6\n'))
  58. if t == 1:
  59. t1 = raw_input('Enter your English word here to see Japanese translation\n')
  60. if t1 in dictEnAlph:
  61. print dictEnAlph[t1]
  62. elif t1 in dictEnWrd:
  63. print dictEnWrd[t1]
  64. if t == 2:
  65. t3 = raw_input('Enter your Japanese word here to see English translation\n')
  66. if t3 in dictJpAlph:
  67. print dictJpAlph[t3]
  68. elif t3 in dictJpWrd:
  69. print dictJpWrd[t3]
  70. if t == 3:
  71. t2 = raw_input('Enter your Japanese word with Hiragana symbols\n')
  72. t22 = raw_input('Enter the translation value of this Hiragana word\n')
  73. if t2 not in dictJpWrd:
  74. dictJpWrd[t2] = t22
  75. dictEnWrd[t22] = t2
  76. print t2, 'and', dictJpWrd, dictEnWrd, 'has been updated!'
  77. if t == 4:
  78. t4 = raw_input('Enter your English word')
  79. t44 = raw_input('Enter its Japanese translation')
  80. if t4 not in dictEnWrd:
  81. dictEnWrd[t4] = t44
  82. dictJpWrd[t44] = t4
  83. if t == 6:
  84. #r = random.choice([dictEnWrd.keys()])
  85. r = random.sample(dictEnWrd, 1)
  86. n = r[0]
  87. print 'Try to guess what is the translation of', r, '?\n'
  88. m = raw_input('Guess\n')
  89.  
  90. if m == dictEnWrd[n]:
  91. print 'Congratulations!'
  92. else:
  93. print 'Fail! Try again'
  94. print 'さよなら!'
  95.  
  96.  
  97. raw_input('\n\nP')
Runtime error #stdin #stdout #stderr 0.01s 11496KB
stdin
Standard input is empty
stdout
いらっしやい!
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

Enter your choice of action between 0 and 6
stderr
Traceback (most recent call last):
  File "prog.py", line 57, in <module>
EOFError: EOF when reading a line