hanja: ํ์-ํ๊ธ ๋ณํ ๋ผ์ด๋ธ๋ฌ๋ฆฌ
ํ์-ํ๊ธ ๋ณํ๊ธฐ
__\ ์์ ์ฌ์ฉ๋๋ ๋ชจ๋์
๋๋ค.
__ http://hanja.suminb.com
Improve Hanja Library
์ฌ์ฉ ํ์๋ค๊ฐ ๋น ์ง ํ์ ๋๋ ํ๋ฆฐ ๋
์์ ๋ฐ๊ฒฌํ์๋ฉด ์ด ๋งํฌ <https://docs.google.com/forms/d/e/1FAIpQLScAtw6ylAhy1t0hMn5K25ZbN1vSNPlRdUtebS9PVtKeLQRfvw/viewform>
_
๋ฅผ ํตํด ์ ๋ณดํด์ฃผ์ธ์. ํ์ธ ํ ๋ฐ์ํ๋๋ก ํ๊ฒ ์ต๋๋ค. GitHub์ ํตํด ์ง์ PR์
๋ณด๋ด์ฃผ์
๋ ์ข์ต๋๋ค.
Installation
.. code-block:: console
pip install hanja
Usage
ํ์ํ ๋ชจ๋ import ํ๊ธฐ
.. code-block:: python
>>> import hanja
>>> from hanja import hangul
ํ๊ธ ์ด์ฑ, ์ค์ฑ, ์ข
์ฑ ๋ถ๋ฆฌ
.. code-block:: python
hangul.separate('๊ฐ')
(0, 0, 0)
hangul.separate('๊น')
(1, 0, 0)
ํํ(tuple)์ ๋ง์ง๋ง ์์๊ฐ 0์ด๋ฉด ์ข
์ฑ์ด ์๋ ๊ธ์๋ผ๊ณ ํ๋จํ ์ ์๋ค.
.. code-block:: python
hangul.separate('ํ')
(18, 0, 4)
'ใ
'์ 19๋ฒ์งธ ์์, 'ใ
'๋ ์ฒซ๋ฒ์งธ ๋ชจ์, 'ใด'์ ๋ค์ฏ๋ฒ์งธ ์์์ด๋ผ๋ ๊ฒ์ ์ ์ ์๋ค.
์ด์ฑ, ์ค์ฑ, ์ข
์ฑ์ ์กฐํฉํ์ฌ ํ ๊ธ์๋ฅผ ๋ง๋ฆ
.. code-block:: python
>>> hangul.build(0, 0, 0)
'๊ฐ'
์ฃผ์ด์ง ๊ธ์๊ฐ ํ๊ธ์ธ์ง์ ์ฌ๋ถ๋ฅผ ํ๋ณ
````````````````````````````````````
.. code-block:: python
>>> hangul.is_hangul('๊ฐ')
True
>>> hangul.is_hangul('a')
False
ํ๊ธ๋ก ๋ ๋ถ๋ถ๊ณผ ํ์๋ก ๋ ๋ถ๋ถ์ ๋ถ๋ฆฌ
``````````````````````````````````````
๋ฆฌ์คํธ๊ฐ ์๋ ์ ๋ค๋ ์ดํฐ(generator)๋ฅผ ๋ฐํํ๋ค.
.. code-block:: python
>>> '|'.join(hanja.split_hanja('ๅคง้ๆฐๅ์ ๆฐไธปๅ
ฑๅๅ์ด๋ค.'))
ๅคง้ๆฐๅ|์ |ๆฐไธปๅ
ฑๅๅ|์ด๋ค.
>>> [x for x in hanja.split_hanja('ๅคง้ๆฐๅ์ ๆฐไธปๅ
ฑๅๅ์ด๋ค.')]
['ๅคง้ๆฐๅ', '์ ', 'ๆฐไธปๅ
ฑๅๅ', '์ด๋ค.']
์ฃผ์ด์ง ๊ธ์๊ฐ ํ์์ธ์ง์ ์ฌ๋ถ๋ฅผ ํ๋ณ
````````````````````````````````````
.. code-block:: python
>>> hanja.is_hanja('้')
True
>>> hanja.is_hanja('ํ')
False
๋ฌธ์ฅ ๋ณํ
`````````
์นํ ๋ชจ๋ ๋ณํ:
.. code-block:: python
>>> hanja.translate('ๅคง้ๆฐๅ์ ๆฐไธปๅ
ฑๅๅ์ด๋ค.', 'substitution')
'๋ํ๋ฏผ๊ตญ์ ๋ฏผ์ฃผ๊ณตํ๊ตญ์ด๋ค.'
ํผ์ฉ ๋ชจ๋ ๋ณํ (text):
.. code-block:: python
>>> hanja.translate('ๅคง้ๆฐๅ์ ๆฐไธปๅ
ฑๅๅ์ด๋ค.', 'combination-text')
'ๅคง้ๆฐๅ(๋ํ๋ฏผ๊ตญ)์ ๆฐไธปๅ
ฑๅๅ(๋ฏผ์ฃผ๊ณตํ๊ตญ)์ด๋ค.'
ํผ์ฉ ๋ชจ๋ ๋ณํ version 2 (text):
.. code-block:: python
>>> hanja.translate('ๅคง้ๆฐๅ์ ๆฐไธปๅ
ฑๅๅ์ด๋ค.', 'combination-text-reversed')
'๋ํ๋ฏผ๊ตญ(ๅคง้ๆฐๅ)์ ๋ฏผ์ฃผ๊ณตํ๊ตญ(ๆฐไธปๅ
ฑๅๅ)์ด๋ค.'
ํผ์ฉ ๋ชจ๋ ๋ณํ (HTML):
.. code-block:: python
>>> hanja.translate(u'ๅคง้ๆฐๅ์ ๆฐไธปๅ
ฑๅๅ์ด๋ค.', 'combination-html')
'<span class="hanja">ๅคง้ๆฐๅ</span><span class="hangul">(๋ํ๋ฏผ๊ตญ)</span>์ <span class="hanja">ๆฐไธปๅ
ฑๅๅ</span><span class="hangul">(๋ฏผ์ฃผ๊ณตํ๊ตญ)</span>์ด๋ค.'