Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- """ dictionary = [
- # consonant letters
- 'ㄱ', # = k / g
- 'ㄴ', # = n
- 'ㄷ', # = d / t
- 'ㄹ', # = r / l
- 'ㅁ', # = m
- 'ㅇ', # = none / ng
- 'ㅂ', # = b
- 'ㅅ', # = s
- 'ㅈ', # = j
- 'ㅎ', # = h
- # vowels letters
- 'ㅣ', # = i
- 'ㅏ', # = a
- 'ㅓ', # = eo (Romanized as “eo” but it sounds closer to “uh” in English)
- 'ㅡ', # = eu
- 'ㅜ', # = u
- 'ㅗ', # = o
- # iotized vowels
- 'ㅑ', # = ya
- 'ㅕ', # = yeo
- 'ㅛ', # = yo
- 'ㅠ', # = yu
- # double ("tense") consonants
- 'ㄲ', # = kk
- 'ㄸ', # = tt
- 'ㅃ', # = pp
- 'ㅆ', # = ss
- 'ㅉ', # = jj
- # consonant clusters
- 'ㄳ', # = gs
- 'ㄵ', # = nj
- 'ㄶ', # = nh
- 'ㄺ', # = lg
- 'ㄻ', # = lm
- 'ㄼ', # = lb
- 'ㄽ', # = ls
- 'ㄾ', # = lt
- 'ㄿ', # = lp
- 'ㅀ', # = lh
- 'ㅄ', # = bs
- # iotized diphthongs
- 'ㅐ', # = ae
- 'ㅒ', # = yae
- 'ㅔ', # = e
- 'ㅖ', # = ye
- 'ㅢ', # = ui
- # vowels and diphthongs with a w
- 'ㅘ', # = wa
- 'ㅙ', # = wae
- 'ㅚ', # = oe
- 'ㅝ', # = wo
- 'ㅞ', # = we
- 'ㅟ' # = wi
- ] """
- initial_jamo = [ # U+1100 - U+1112
- 'g', 'gg', 'n', 'd',
- 'dd', 'r', 'm', 'b',
- 'bb','s', 'ss', '',
- 'j', 'jj', 'ch', 'k',
- 't', 'p', 'h'
- ]
- medial_jamo = [ # U+1161 - U+1175
- 'a', 'ae','ya','yae',
- 'eo', 'e','yeo','ye',
- 'o','wa','wae','oe',
- 'yo','u','weo','we',
- 'wi','yu','eu','eui',
- 'i'
- ]
- end_jamo = [
- '',' g', 'gg', 'gs',
- 'n', 'nj','nh','d',
- 'l', 'rk', 'rm', 'rb',
- 'rs', 'rt', 'rp', 'rh',
- 'm', 'b', 'bs', 's',
- 'ss', 'ng', 'j', 'ch',
- 'k', 't', 'p', 'h'
- ]
- first_unicode = 0xac00 # equal to 44032
- last_unicode = 0xd7a3
- def romanizate(text):
- romanized = u''
- for chr in text:
- if first_unicode <= ord(chr) <= last_unicode:
- head = int(math.floor((ord(chr - first_unicode)) / 588))
- head1 = int(math.floor((ord(chr - first_unicode)) % 588))
- body = int(math.floor(head1 / 588))
- tail = int(math.floor(head1 % 588))
- romanized += initial_jamo[head]
- romanized += medial_jamo[body]
- romanized += end_jamo[tail]
- def is_correct(symbol, result):
- return result == kroman.parse(symbol)
- def do_u_want_to_play(count_of_symbols):
- if count_of_symbols < len(alphabet):
- temp_alphabet = alphabet
- for i in range(count_of_symbols):
- rand_index = random.randrange(count_of_symbols - i)
- test_symbol = temp_alphabet[rand_index]
- answer = input("let me translate for {}: ".format(test_symbol))
- if is_correct(test_symbol, answer):
- print("Right")
- temp_alphabet.pop(rand_index)
- else:
- print("Try harder, right answer is: {}".format(kroman.parse(test_symbol)))
- do_u_want_to_play(10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement