Skip to main content

HanjaDict (한자사전)

PyPI version Python Versions License Downloads

A lightweight Python package for looking up Hanja (Chinese characters used in Korea) information, specifically focusing on 훈음 (hun-eum).

Installation

pip install hanjadict

Usage

import hanjadict

# Look up a Hanja character
result = hanjadict.lookup("雪")
print(result)
# Output: '눈 설'

# Check if a character is Hanja
is_hanja = hanjadict.is_hanja("雪")
print(is_hanja)
# Output: True

# Get only the pronunciation (음/音) part
pron = hanjadict.pronunciation("雪")
print(pron)
# Output: '설'

# Access the raw dictionary data (a plain dict: character -> 훈음)
raw_data = hanjadict.table_data
print(len(raw_data))

# If the character is not found, returns None
result = hanjadict.lookup("xyz")
print(result)  # Output: None

Dictionary data

This package does not ship dictionary data. Only the lookup code is distributed; you supply your own table.json, a UTF-8 JSON object mapping a single Hanja character to its 훈음 string:

{
  "雪": "눈 설",
  "山": "메 산",
  "燕": "제비 연/잔치 연"
}

hanjadict looks for the data in this order:

  1. The path in the HANJADICT_TABLE environment variable
  2. table.json inside the installed hanjadict package directory

If neither is found, table_data is an empty dict and every lookup returns None / False.

Sources you can legally redistribute and convert into this format include Unicode's Unihan database (kHangul, Unicode License) and libhangul's hanja.txt (LGPL). Check each source's license before redistributing a table.json built from it.

Features

  • Simple API with intuitive functions
  • Lightweight with no external dependencies
  • Bring-your-own dictionary data (see above)
  • Access to raw dictionary data for advanced usage

Available Functions

  • lookup(c): Get the full 훈음 information for a character
  • is_hanja(c): Check if a character is a valid Hanja in the dictionary
  • pronunciation(c): Extract only the Sino-Korean pronunciation (음/音) part
  • table_data: Access the raw dictionary data (as a Python dictionary)

What is 훈음 (Hun-eum)?

훈음 (訓音) refers to the combined Korean native word meaning (훈/訓) and Sino-Korean pronunciation (음/音) of a Hanja character. For example:

  • 雪 (눈 설): "눈" is the 훈 (native Korean word for "snow") and "설" is the 음 (Sino-Korean pronunciation)
  • 山 (메 산): "메" is the 훈 (native Korean word for "mountain") and "산" is the 음

This concept is unique to Korean language and helps learners understand both the meaning and pronunciation of Hanja characters.

Special Formats Handled

The pronunciation() function can handle various dictionary formats:

  • Normal format: "눈 설" → returns "설"
  • Comma-separated: "샘솟을 집, 샘솟을 설" → returns "집"
  • Slash-separated: "제비 연/잔치 연" → returns "연"
  • Parentheses: "영양 령(영)" → returns "령"

License

The MIT License in this repository applies only to the source code. No license is granted to any third-party dictionary content or data. Any table.json you use with this package is governed by the license of its own source.

Metadata

Release files for hanjadict 0.5.0

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

Source distribution (sdist)

Source distribution for hanjadict 0.5.0
File Size Uploaded Provenance Actions
hanjadict-0.5.0.tar.gz 6.9 kB Without provenance Details for hanjadict-0.5.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hanjadict 0.5.0
File Interpreter ABI Platform Actions
hanjadict-0.5.0-py3-none-any.whl Python 3 none any Details for hanjadict-0.5.0-py3-none-any.whl

Total release size: 13.0 kB

Release files / hanjadict-0.5.0.tar.gz

Download URL hanjadict-0.5.0.tar.gz
Size 6.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6c3dd882f35511fa8033803c85c7099a686fc8c6de9e5fea990789a7ee06d7bb
BLAKE2b-256 checksum
How to use checksums
5e455118823fea9fce1187af65a8d8d58d5cc5f3fd36e88a2399981061698e1b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / hanjadict-0.5.0-py3-none-any.whl

Download URL hanjadict-0.5.0-py3-none-any.whl
Size 6.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2b9e60e8e5553a677bd351f9e2925ddbac3160246f2cfd10f43d841c457059e4
BLAKE2b-256 checksum
How to use checksums
448096dd54db0f81f492672f515d9cb164cf02e695b4bf432af77033d8266f6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for hanjadict 0.5.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 release files No provenance

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