Hangul
A library for automatically romanizing Korean text.
Supports the two primary systems for romanizing Hangul:
- McCune-Reischauer (an older system which includes diacritics and has a stronger emphasis on representing actual pronunciation)
- Revised (the standard used by the government of South Korea; does not use diacritics but the pronunciation is less obvious)
Usage
Given a string containing Korean text (possibly intermingled with non-Korean characters):
require 'hangul_tools'
s = 'I told him, "안녕하십니까."'
puts HangulTools.romanize(s, system: :revised)
# => I told him, "annyeonghasimnikka."
puts HangulTools.romanize(s, system: :mccune_reischauer)
# => I told him, "annyŏnghashimnikka."
If you omit the system to use, it defaults to revised:
s = 'I told him, "안녕하십니까."'
puts HangulTools.romanize(s)
# => I told him, "annyeonghasimnikka."
Caveats
The results are not guaranteed to be accurate for all inputs, and are not even guaranteed to conform exactly to the Revised or McCune-Reischauer systems.
If you notice an inaccuracy, please:
- Write a failing test that demonstrates the problem.
- Fix the problem.
- Submit a pull request.
Thank you!