Skip to content

Instantly share code, notes, and snippets.

@shiumachi
Created April 18, 2019 08:25
Show Gist options
  • Save shiumachi/c89102e7e7f2a98c802fc37e5c58e99e to your computer and use it in GitHub Desktop.
Save shiumachi/c89102e7e7f2a98c802fc37e5c58e99e to your computer and use it in GitHub Desktop.
pyspa-bot: phonics, lower, upper command
# phonics
ph = {"a": "アッ", "b": "バッ", "c": "カッ", "d": "ダッ", "e": "エ", "f": "フッ", "g": "グッ", "h": "ハッ", "i": "イ", "j": "ジャ", "k": "クッ", "l": "ル", "m": "ム", "n": "ヌ", "o": "オ", "p": "パッ", "q": "カッ", "r": "ル", "s": "ス", "t": "ツ", "u": "ウッ", "v": "ヴッ", "w": "ウッ", "x": "クス", "y": "ヤッ", "z": "ズ"}
arr = []
for a,b in ph.items():
arr.append(f'rsub("{a}", "{b}",')
result = ''.join(arr) + "{@1}"" + ')' * len(arr)
result
# upper
d = {}
for c in range(97,123):
d[chr(c)] = chr(c-32)
arr = []
for a,b in d.items():
arr.append(f'rsub("{a}", "{b}",')
result = ''.join(arr) + "{@1}" + ')' * len(arr)
result
# lower
d = {}
for c in range(97,123):
d[chr(c-32)] = chr(c)
arr = []
for a,b in d.items():
arr.append(f'rsub("{a}", "{b}",')
result = ''.join(arr) + "{@1}" + ')' * len(arr)
result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment