def romanize(value): value = kana.to_katakana(value) def step1(matcher): return KANA_TO_ROMAJI_MAP[matcher.group(1)] value = RE_KANA_TWO.sub(step1, value) value = RE_KANA_ONE.sub(step1, value) # ッta -> tta def step2(matcher): char = matcher.group(1) return '%s%s' % (char, char) value = RE_CONSONANTS.sub(step2, value) # oー -> oo def step3(matcher): vowel = matcher.group(1) return '%s%s' % (vowel, vowel) value = RE_VOWELS.sub(step3, value) return value
def test_mixed(): output = kana.to_hiragana("カラマーゾフの兄弟") assert output == "からまーぞふの兄弟" output = kana.to_katakana("からまーぞふの兄弟") assert output == "カラマーゾフノ兄弟"
def func(input, expected): output = kana.to_katakana(input) assert output == expected, "%s expected, got %s" % (expected, output)
def func(input, expected): output = kana.to_hiragana(input) assert isinstance(output, six.text_type) and output == expected output = kana.to_katakana(input) assert isinstance(output, six.text_type) and output == expected