Huge News!Announcing our $40M Series B led by Abstract Ventures.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