Install & Compatibility
Where this runs
tested against v0.1.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 35.7MB
glibcpy 3.10–3.910 runs
installs and imports cleanly · install 3.3s · import 0.000s · 37MB
35MB installed
● package 35MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
G2pkk
✓ from g2pkk import G2pkk
This quickstart demonstrates how to initialize the G2pkk converter and use it to transform Korean text into its romanized phonetic representation. It includes a crucial step to ensure the NLTK 'punkt' resource is downloaded, which is a common prerequisite for many NLP libraries.
import nltk
from g2pkk import G2pkk
# Important: Download NLTK 'punkt' resource if not already done
try:
nltk.data.find('tokenizers/punkt')
except nltk.downloader.DownloadError:
print("Downloading NLTK 'punkt' resource...")
nltk.download('punkt')
# Initialize the G2P converter
g2p = G2pkk()
# Convert Korean text to its phoneme representation
text = "안녕하세요 g2p 입니다. 반갑습니다. 123."
result = g2p(text)
print(f"Original: {text}")
print(f"Phonetic: {result}")
# Example with specific romanization
text_roman = g2p("한국어")
print(f"'한국어' phonetic: {text_roman}")
Debug
Known issues
gotchaThe `nltk` library, a dependency of g2pkk, requires the 'punkt' tokenizer resource to be downloaded separately. Failure to do so will result in a `LookupError`.fixRun `import nltk; nltk.download('punkt')` once before using g2pkk. It's good practice to include this check at the start of your application. affects: All versions
gotchag2pkk is in early development (version 0.1.x), which means its API might undergo non-backward-compatible changes in future minor or patch releases as it approaches a stable 1.0 version.fixPin your `g2pkk` dependency to exact versions (e.g., `g2pkk==0.1.2`) in your `requirements.txt` to prevent unexpected breaking changes with new releases. Review release notes for any new versions carefully.
affects: All versions prior to 1.0.0
gotchaInput text must be primarily Korean. While it handles numbers and some English, its core functionality and accuracy are designed for Korean grapheme-to-phoneme conversion.fixEnsure that the majority of the input text is Korean for optimal results. Mixed language input might produce less accurate or less natural-sounding romanizations for non-Korean parts.
affects: All versions
Upgrade
Version history
0.1.2latest on PyPI · released Sep 5, 2022
Audit
Dependencies
jamotoolsrequiredRequired for Korean character processing.
jamorequiredRequired for Korean character processing.
nltkrequiredRequired for natural language processing tasks, specifically the 'punkt' tokenizer.
pykospacingrequiredUsed for Korean spacing correction, improving G2P accuracy.
korean-romanizerrequiredUsed for romanization of Korean text.