Hangul Romanize
hangul-romanize is a Python library for romanizing Hangul strings, specifically adhering to the academic notation rules (국립국어원 학술 표기법) of the National Institute of Korean Language. As of version 0.1.0, it provides tools for converting Korean text into the Latin alphabet based on these scholarly guidelines.
Common errors
-
ModuleNotFoundError: No module named 'hangul_romanize'
cause The 'hangul-romanize' package has not been installed in the current Python environment.fixRun `pip install hangul-romanize` to install the library. -
AttributeError: module 'hangul_romanize' has no attribute 'romanize'
cause Attempting to call a global `romanize` function directly from the `hangul_romanize` module, which does not exist. The library's API requires instantiation of the `Transliter` class.fixYou must first import and instantiate the `Transliter` class, then call its `translit` method: `from hangul_romanize import Transliter; from hangul_romanize.rule import academic; transliter = Transliter(academic); romanized = transliter.translit('안녕하세요')`. -
Unexpected Romanization output for a common word or name (e.g., '김치' not romanizing as expected)
cause The library uses a specific academic rule set, which might not align with other common romanization systems (like Revised Romanization or older informal spellings) or perceived 'correct' pronunciations based on non-standard rules.fixReview the `hangul-romanize` GitHub repository and documentation to understand the precise academic rules it implements. If a different romanization standard is desired, consider using an alternative library or implementing custom mapping rules.
Warnings
- gotcha The library primarily implements the 'academic notation rules' (국립국어원 학술 표기법), which may yield different results compared to the more commonly encountered 'Revised Romanization of Korean' (RR) used for public signage, names, and general communication. Users expecting RR may find the output inconsistent with their expectations.
- gotcha Korean romanization, regardless of the system, often struggles to perfectly represent all phonetic nuances due to inherent differences in the phonological systems of Korean and Latin alphabets (e.g., distinctions between aspirated/unaspirated consonants, certain vowels).
- deprecated The library's last release was on April 7, 2020. While not explicitly deprecated, the infrequent updates suggest it may not actively incorporate new linguistic research, updated academic standards, or significant Python version compatibility fixes that could arise in the future.
Install
-
pip install hangul-romanize
Imports
- Transliter
import hangul_romanize
from hangul_romanize import Transliter
- academic
from hangul_romanize import academic
from hangul_romanize.rule import academic
Quickstart
from hangul_romanize import Transliter
from hangul_romanize.rule import academic
# Initialize the transliterator with the academic rule set
transliter = Transliter(academic)
# Romanize a Hangul string
hangul_text = u'안녕하세요'
romanized_text = transliter.translit(hangul_text)
print(f"Original: {hangul_text}, Romanized: {romanized_text}")
# Example with another string
hangul_text_2 = u'한글 로마자 변환'
romanized_text_2 = transliter.translit(hangul_text_2)
print(f"Original: {hangul_text_2}, Romanized: {romanized_text_2}")