Skip to content

Instantly share code, notes, and snippets.

@tamuhey
Created November 8, 2019 16:10
Show Gist options
  • Save tamuhey/c7147890b77d9b1fe7b64c75300db0d4 to your computer and use it in GitHub Desktop.
Save tamuhey/c7147890b77d9b1fe7b64c75300db0d4 to your computer and use it in GitHub Desktop.
拗音を促音に変換する
import string
LOWER = "ぁぃぅぇぉっゃゅょゎァィゥェォッャュョヮ"
UPPER = "あいうえおつやゆよわアイウエオツヤユヨワ"
MAP = str.maketrans(dict(zip(LOWER, UPPER)))
def ja_upper(text: str) -> str:
return text.translate(MAP)
assert ja_upper("きょう") == "きよう"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment