hanja: 한자-한글 변환 라이브러리
한자-한글 변환기에서 사용되는 모듈입니다.
Improve Hanja Library
사용 하시다가 빠진 한자 또는 틀린 독음을 발견하시면 이 링크를 통해 제보해주세요. 확인 후 반영하도록 하겠습니다. GitHub을 통해 직접 PR을 보내주셔도 좋습니다.
Installation
pip install hanja
Usage
필요한 모듈 import 하기
>>> import hanja
>>> from hanja import hangul
한글 초성, 중성, 종성 분리
>>> hangul.separate('가')
(0, 0, 0)
>>> hangul.separate('까')
(1, 0, 0)
튜플(tuple)의 마지막 원소가 0이면 종성이 없는 글자라고 판단할 수 있다.
>>> hangul.separate('한')
(18, 0, 4)
‘ㅎ’은 19번째 자음, ‘ㅏ’는 첫번째 모음, ‘ㄴ’은 다섯번째 자음이라는 것을 알 수 있다.
초성, 중성, 종성을 조합하여 한 글자를 만듦
>>> hangul.build(0, 0, 0)
'가'
주어진 글자가 한글인지의 여부를 판별
>>> hangul.is_hangul('가')
True
>>> hangul.is_hangul('a')
False
한글로 된 부분과 한자로 된 부분을 분리
리스트가 아닌 제네레이터(generator)를 반환한다.
>>> '|'.join(hanja.split_hanja('大韓民國은 民主共和國이다.'))
大韓民國|은 |民主共和國|이다.
>>> [x for x in hanja.split_hanja('大韓民國은 民主共和國이다.')]
['大韓民國', '은 ', '民主共和國', '이다.']
주어진 글자가 한자인지의 여부를 판별
>>> hanja.is_hanja('韓')
True
>>> hanja.is_hanja('한')
False
문장 변환
치환 모드 변환:
>>> hanja.translate('大韓民國은 民主共和國이다.', 'substitution')
'대한민국은 민주공화국이다.'
혼용 모드 변환 (text):
>>> hanja.translate('大韓民國은 民主共和國이다.', 'combination-text')
'大韓民國(대한민국)은 民主共和國(민주공화국)이다.'
혼용 모드 변환 version 2 (text):
>>> hanja.translate('大韓民國은 民主共和國이다.', 'combination-text-reversed')
'대한민국(大韓民國)은 민주공화국(民主共和國)이다.'
혼용 모드 변환 (HTML):
>>> hanja.translate(u'大韓民國은 民主共和國이다.', 'combination-html')
'<span class="hanja">大韓民國</span><span class="hangul">(대한민국)</span>은 <span class="hanja">民主共和國</span><span class="hangul">(민주공화국)</span>이다.'
Metadata
Release files for hanja 0.15.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| hanja-0.15.1.tar.gz | 122.7 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hanja-0.15.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 246.9 kB
Release files / hanja-0.15.1.tar.gz
| Download URL | hanja-0.15.1.tar.gz |
|---|---|
| Size | 122.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
851edd467612d453ef6905fe975aa9aae50f2c42f84f003545020945724dd188
|
|
BLAKE2b-256 checksum How to use checksums |
5a76e21c7f8d4bf3dcb04e462c17ee9c04a0a1d1f2cec1e84a48ca9d5f3c5fda
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.3
|
Release files / hanja-0.15.1-py3-none-any.whl
| Download URL | hanja-0.15.1-py3-none-any.whl |
|---|---|
| Size | 124.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
66981f7dedf7ad298661d7d58f2702ea84304617fbe52478a42833f9819d75be
|
|
BLAKE2b-256 checksum How to use checksums |
13a717502d7815b97bbaa593226377e99a294980cfe913f4baf27d7771909ee0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.3
|
Security for hanja 0.15.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.