Esempio n. 1
0
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
Esempio n. 2
0
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
Esempio n. 3
0
def test_mixed():
    output = kana.to_hiragana("カラマーゾフの兄弟")
    assert output == "からまーぞふの兄弟"

    output = kana.to_katakana("からまーぞふの兄弟")
    assert output == "カラマーゾフノ兄弟"
Esempio n. 4
0
 def func(input, expected):
     output = kana.to_katakana(input)
     assert output == expected, "%s expected, got %s" % (expected, output)
Esempio n. 5
0
    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
Esempio n. 6
0
 def func(input, expected):
     output = kana.to_katakana(input)
     assert output == expected, "%s expected, got %s" % (expected, output)
Esempio n. 7
0
    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
Esempio n. 8
0
def test_mixed():
    output = kana.to_hiragana("カラマーゾフの兄弟")
    assert output == "からまーぞふの兄弟"

    output = kana.to_katakana("からまーぞふの兄弟")
    assert output == "カラマーゾフノ兄弟"