(Show Table Of Contents)
(Hide Table Of Contents)

Python Module

Installing

The stable version is available in PyPI:

$ easy_install hangulize

We can also get a development version from the GitHub repository:

$ pip install git+git://github.com/sublee/hangulize.git#egg=hangulize
$ git clone git://github.com/sublee/hangulize.git
$ cd hangulize
$ python setup.py install

API

Front-end

hangulize.hangulize(string, code=None, iso639=None, lang=None, logger=None)

Transcribes a loanword to Hangul.

>>> print hangulize(u'gloria', 'ita')
글로리아
Parameters:
  • string – an loan word
  • code – a language code as ISO 639-3. if lang is not given, it is required
  • lang – a Language instance
  • logger – if the logger instance is given, reports result by each steps
hangulize.supports(code)

Checks if hangulize supports the given language.

>>> supports('ita')
True
>>> supports('kat.narrow')
True
>>> supports('kor')
False
hangulize.get_lang(code, iso639=None)

Returns a language instance from the given code.

hangulize.langs.list_langs()

Returns the supported language code list.

Utility

hangulize.normalization.normalize_roman(string, additional=None)

Removes diacritics from the string and converts to lowercase.

>>> normalize_roman(u'Eèé')
u'eee'
hangulize.processing.complete_syllable(syllable)

Inserts the default jungseong or jongseong if it is not exists.

>>> complete_syllable((Jungseong(YO),))
(u'ㅇ', u'ㅛ', u'')
>>> print hangulize.hangul.join(_)

hangulize.processing.complete_syllables(phonemes)

Separates each syllables and completes every syllable.

hangulize.processing.split_phonemes(word)

Returns the splitted phonemes from the word.

>>> split_phonemes(u'안녕') 
(<Choseong 'ㅇ'>, <Jungseong 'ㅏ'>, <Jongseong 'ㄴ'>,
 <Choseong 'ㄴ'>, <Jungseong 'ㅕ'>, <Jongseong 'ㅇ'>)
hangulize.processing.join_phonemes(phonemes)

Returns the word from the splitted phonemes.

>>> print join_phonemes((Jungseong(A), Jongseong(N),
...                      Choseong(N), Jungseong(YEO), Jongseong(NG)))
안녕
Fork me on GitHub