Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

고놈 KorNorm

Korean text preprocessing — text normalization plus a G2P engine built on the Standard Korean Pronunciation rules (표준발음법).

KorNorm turns raw Korean text — digits, units, symbols, English words and all — into hangul that reads the way a Korean speaker would actually say it out loud. It was built with TTS front-ends in mind, but it is just as much at home normalizing ASR transcripts, building pronunciation dictionaries, or anywhere else Korean text needs to match speech.

>>> from kornorm import dealers_choice, apply_phonology
>>> apply_phonology(dealers_choice("6·25 전쟁은 1950년에 일어났다"), output_format="hangul")
'유기오 전쟁은 천구배고심녀네 이러낟따'
>>> apply_phonology(dealers_choice("이 old school 감성의 MP3 파일은 3.5MB밖에 안 한다"), output_format="hangul")
'이 올드 스쿨 감성의 엠피쓰리 파이른 삼 쩜 오메가바이트바께 안 한다'

Installation

pip install kornorm

Pure Python (3.10+, verified on 3.10 and 3.12). The only direct dependencies are pecab and pyarrow — no C toolchain, no MeCab install. Note that pecab's own metadata pulls in pytest, emoji, numpy, regex and pygments as transitive dependencies; that is pecab's doing, and KorNorm cannot slim it down — plan for it if you expect a minimal environment.

On first use, KorNorm performs a one-time setup:

  • it patches and rebuilds pecab's bundled dictionary (takes about 40 seconds), and
  • it downloads the CMU Pronouncing Dictionary (~3.6 MB) for English word conversion. If the download fails (e.g. offline), everything else still works — English words are simply left as spelled-out letters.

Both steps write into site-packages, so run the first call in an environment with write access (see Known limitations).

Usage

Two layers, used separately or chained:

>>> from kornorm import dealers_choice, apply_phonology
>>> dealers_choice("45,000원짜리 5G 요금제")          # normalization only
'사만오천원짜리 파이브쥐 요금제'
>>> apply_phonology("맑게 갠 하늘과 꽃잎", output_format="hangul")  # G2P only
'말께 갠 하늘과 꼰닙'
>>> apply_phonology(dealers_choice("몸무게가 70.5kg 나간다"), output_format="hangul")
'몸무게가 칠씹 쩜 오킬로그램 나간다'
  • dealers_choice — a 14-step normalization preset: numbers, currencies, phone numbers, dates & times, interpunct readings (6·25), units, decimals, alphanumeric combos (MP3), English words (via CMU dict + 외래어 표기법), leftover Latin letters.
  • apply_phonology — the phonology engine. Implements 표준발음법 rule by rule on top of morphological analysis, with pronunciations from the Standard Korean Language Dictionary (표준국어대사전) applied first through an O(1) trie lookup. Output formats: "hangul" (composed syllables), "positional" / "compat" (decomposed jamo for speech-model token inputs). It wraps a module-level PhonologicProcessor — instantiate or subclass that class directly for more control; the instance is callable, so it handles just like g2pK's G2p.
  • StreamPipeline / BatchPipeline — lazy generator or multiprocessing wrappers for corpus-scale processing.

What sets the G2P apart from existing libraries in the g2pK lineage:

  • Dictionary-first: lexical pronunciations (대관령[대괄령], 공권력[공꿘녁], …) come from a compiled 표준국어대사전 lookup instead of a hardcoded exception list.
  • Per-rule word-boundary policy: each rule decides whether it may cross a space, and cross-word rules fire only on cohesive word pairs (옷 입고 한 일 → [온 닙꼬 한 닐]).
  • Morpheme-aware rules: functional vs. lexical morpheme distinctions resolve classic edge cases (꽂히다[꼬치다] vs. 낮 한때[나탄때]).

Known limitations (alpha)

  • The first-run setup cannot complete in read-only environments (e.g. locked-down Docker images) — trigger the first call once with write access to site-packages.
  • Symbols outside the conversion tables (…, ½, emoji) pass through unread, and the unit table — broad as it is — is not exhaustive: a compound unit it cannot match is read as best the later steps can (120km/h → 백이십킬로미터슬래쉬에이치).
  • Context-dependent homographs (잠자리 bed/dragonfly …) are resolved by a cue-word vote, which is an approximation.
  • Not yet implemented: email/URL reading, spacing correction, sentence-ending unification.

Changelog

  • 0.0.1b1 — added read-only finders that report (start, end, match) spans without touching the text, for profiling a corpus before deciding how to normalize it: find_symbols in heuristics (the twin of purge_symbols), and nine find_ twins of the converters in alphanumeric (find_units, find_currencies, find_phone_number, find_bound_numerals, …), each guaranteed to detect exactly the inputs its converter would rewrite.
  • 0.0.0a2 — removed the normalize wrapper: compose the two layers yourself (apply_phonology(dealers_choice(text), output_format="hangul")). Fixed output_format="hangul" crashing on any non-hangul character (punctuation included) and bare 0 disappearing from numbers; numbers with a leading zero now read as codes (007 → 공공칠). Added pos() (morphological tags as the engine sees them), strip_punctuation/collapse_whitespace, find_text_degeneration, regex targets for the symbol removers, and charge/energy compound units (mAh, kWh, %p, …).
  • 0.0.0a1 — first release.

Credits

Built on the shoulders of: 표준국어대사전 (National Institute of Korean Language), pecab by Hyunwoong Ko, g2pK by Kyubyong Park and its descendants, python-jamo by Joshua Dong, and the CMU Pronouncing Dictionary. See the repository for the full lineage.

License

Released under the MOST OF IT IS NOT MY CODE PUBLIC LICENSE — see the LICENSE file. It means what it says: wherever a source is credited, the upstream license (MIT, GPL, Apache-2.0, …) remains in force. Everything else — the parts that are the author's own ideas — is basically 0BSD: the author didn't exactly write the code anyway (an AI coding agent did), so feel free to use it however you like.

Metadata

Release files for kornorm 0.0.1b1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kornorm 0.0.1b1
File Size Uploaded
kornorm-0.0.1b1.tar.gz 6.8 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for kornorm 0.0.1b1
File Interpreter ABI Platform
kornorm-0.0.1b1-py3-none-any.whl Python 3 none any Details

Total release size: 13.7 MB

Release files / kornorm-0.0.1b1.tar.gz

Download URL kornorm-0.0.1b1.tar.gz
Size 6.8 MB
Tags Source
SHA-256 checksum
How to use checksums
3ac3db300867572250a700d2670a87c43b43eae399b88027304501ad355317d7
BLAKE2b-256 checksum
How to use checksums
4d4aa09e43b2d2c1c830f0500c497c89c2a8e5bc587c41c5633d836ed3fdb943
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 31, 2026.

Transparency log

Release files / kornorm-0.0.1b1-py3-none-any.whl

Download URL kornorm-0.0.1b1-py3-none-any.whl
Size 6.8 MB
Tags Python 3
SHA-256 checksum
How to use checksums
2b6979e1ba955da50e98800fc0e605e5ca29cfc5883ed19d32682ad2ec8c2f25
BLAKE2b-256 checksum
How to use checksums
7f62a1a76f4f69329cb2cf95121dafd94564c6034f3cce2a6ac8d58739d6891d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 31, 2026.

Transparency log
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page