Skip to content

Instantly share code, notes, and snippets.

@theeluwin
Last active August 3, 2016 08:59
Show Gist options
  • Select an option

  • Save theeluwin/7fd1640eb8e7a284dfc038551ee76420 to your computer and use it in GitHub Desktop.

Select an option

Save theeluwin/7fd1640eb8e7a284dfc038551ee76420 to your computer and use it in GitHub Desktop.
모나드 => 몬앋으
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from korean import hangul
def pull(text):
exploded = [list(hangul.split_char(c)) if hangul.is_hangul(c) else c for c in text]
for i in range(len(exploded)):
if i == 0:
continue
a = exploded[i - 1]
b = exploded[i]
if type(a) is list and type(b) is list:
if not a[2] and b[0] != "ㅇ":
next = b[0]
if next == "ㅉ":
next = "ㅈ"
elif next == "ㅃ":
next = "ㅂ"
elif next == "ㄸ":
next = "ㄷ"
a[2] = next
b[0] = "ㅇ"
return "".join([hangul.join_char(c) if type(c) is list else c for c in exploded])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment