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
Metadata
Release files for hgtk 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hgtk-0.2.1-py2.py3-none-any.whl | Python 3, Python 2 | none | any | Details for hgtk-0.2.1-py2.py3-none-any.whl |
Release files / hgtk-0.2.1-py2.py3-none-any.whl
| Download URL | hgtk-0.2.1-py2.py3-none-any.whl |
|---|---|
| Size | 12.0 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
f3e33dacf6ab2564f6257418b718e2c7a4ae9fffa32e18d6c4f6278b72ba73ee
|
|
BLAKE2b-256 checksum How to use checksums |
4cd0d62a73954ab95a8d3967a063c371c16feddfb8bd2957fd11691adf7834e8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.6.0 importlib_metadata/4.8.2 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.2
|
Security for hgtk 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.