New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

hgtk

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hgtk

Toolkit for Hangul composing, decomposing and etc...

  • 0.2.1
  • PyPI
  • Socket score

Maintainers
1

Simple Toolkit for Hangul

base code forked from https://github.com/rhobot/Hangulpy

한글 자모 분해, 조합(오토마타), 조사 붙이기, 초/중/종 분해조합, 한글/한자/영문 여부 체크 등을 지원합니다.

INSTALL

pip install hgtk

Samples

Letter

Decompose character
>>> hgtk.letter.decompose('감')
('ㄱ', 'ㅏ', 'ㅁ')
Compose character
>>> hgtk.letter.compose('ㄱ', 'ㅏ', 'ㅁ')
'감'

Text

Decompose text
>>> hgtk.text.decompose('학교종이 땡땡땡! hello world 1234567890 ㅋㅋ!')
'ㅎㅏㄱᴥㄱㅛᴥㅈㅗㅇᴥㅇㅣᴥ ㄸㅐㅇᴥㄸㅐㅇᴥㄸㅐㅇᴥ! hello world 1234567890 ㅋᴥㅋᴥ!'

기본 조합 완료 기호는 ᴥ이고, 아래와 같이 compose_code 옵션으로 변경 가능합니다.

>>> hgtk.text.decompose('학교종이 땡땡땡! hello world 1234567890 ㅋㅋ!', compose_code='/')
'ㅎㅏㄱ/ㄱㅛ/ㅈㅗㅇ/ㅇㅣ/ㄸㅐㅇ/ㄸㅐㅇ/ㄸㅐㅇ/! hello world 1234567890 ㅋ/ㅋ/!'

기본 조합기호의 의미는 곰돌이 입니다. 👇

Compose text (Automata)
>>> hgtk.text.compose('ㅎㅏㄱᴥㄱㅛᴥㅈㅗㅇᴥㅇㅣᴥ ㄸㅐㅇᴥㄸㅐㅇᴥㄸㅐㅇᴥ! hello world 1234567890 ㅋᴥㅋᴥ!')
'학교종이 땡땡땡! hello world 1234567890 ㅋㅋ!'

Checker

is hangul text
>>> hgtk.checker.is_hangul('한글입니다')
True
>>> hgtk.checker.is_hangul('no한글입니다')
False
>>> hgtk.checker.is_hangul('it is english')
False
is hanja text
>>> hgtk.checker.is_hanja('大韓民國')
True
>>> hgtk.checker.is_hanja('大한민국')
False
>>> hgtk.checker.is_hanja('대한민국')
False
is latin1 text
>>> hgtk.checker.is_latin1('abcdefghijklmnopqrstuvwxyz')
True
>>> hgtk.checker.is_latin1('한글latin1한')
False
has batchim
>>> hgtk.checker.has_batchim('한')   # '한' has batchim 'ㄴ'
True
>>> hgtk.checker.has_batchim('하')
False

Josa

EUN_NEUN - 은/는
>>> hgtk.josa.attach('하늘', hgtk.josa.EUN_NEUN)
'하늘은'
>>> hgtk.josa.attach('바다', hgtk.josa.EUN_NEUN)
'바다는'
I_GA - 이/가
>>> hgtk.josa.attach('하늘', hgtk.josa.I_GA)
'하늘이'
>>> hgtk.josa.attach('바다', hgtk.josa.I_GA)
'바다가'
EUL_REUL - 을/를
>>> hgtk.josa.attach('하늘', hgtk.josa.EUL_REUL)
'하늘을'
>>> hgtk.josa.attach('바다', hgtk.josa.EUL_REUL)
'바다를'
GWA_WA - 과/와
>>> hgtk.josa.attach('하늘', hgtk.josa.GWA_WA)
'하늘과'
>>> hgtk.josa.attach('바다', hgtk.josa.GWA_WA)
'바다와'
IDA_DA - 이다/다
>>> hgtk.josa.attach('하늘', hgtk.josa.IDA_DA)
'하늘이다'
>>> hgtk.josa.attach('바다', hgtk.josa.IDA_DA)
'바다다'
EURO_RO - 로/으로
>>> hgtk.josa.attach('하늘', hgtk.josa.EURO_RO)
'하늘로'
>>> hgtk.josa.attach('바다', hgtk.josa.EURO_RO)
'바다로'
>>> hgtk.josa.attach('태양', hgtk.josa.EURO_RO)
'태양으로'
RYUL_YUL - 율/률
>>> hgtk.josa.attach('방어', hgtk.josa.RYUL_YUL)
'방어율'
>>> hgtk.josa.attach('공격', hgtk.josa.RYUL_YUL)
'공격률'
>>> hgtk.josa.attach('반환', hgtk.josa.RYUL_YUL)
'반환율'

Const

  • CHO: 초성 리스트

  • JOONG: 중성 리스트

  • JONG: 종성 리스트, 종성이 없는 경우를 대비해 공백 문자가 추가됨

  • JAMO: 공백을 제외한 모든 자모(비조합문자)

  • NUM_CHO: 초성 개수

  • NUM_JOONG: 중성 개수

  • NUM_JONG: 종성 개수

  • FIRST_HANGUL_UNICODE: 유니코드 상의 한글 코드(조합문자) 시작 시점

  • LAST_HANGUL_UNICODE: 유니코드 상의 한글 코드(조합문자) 종료 시점

Exception

예외 처리를 위한 Exception들, 의미는 보이는 대로..

  • NotHangulException
  • NotLetterException
  • NotWordException

##Tested in

  • python 2.6

  • python 2.7

  • python 3.3

  • python 3.4

  • python 3.5

  • python 3.6

  • python nightly build

  • PyPy 2.2.5.

  • Pypy 3 2.4.

  • PyPy 5.3.1


Apache 2.0 License

Keywords

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc