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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hanjadict-0.5.0.tar.gz (6.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hanjadict-0.5.0-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file hanjadict-0.5.0.tar.gz.

File metadata

  • Download URL: hanjadict-0.5.0.tar.gz
  • Upload date:
  • Size: 6.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for hanjadict-0.5.0.tar.gz
Algorithm Hash digest
SHA256 6c3dd882f35511fa8033803c85c7099a686fc8c6de9e5fea990789a7ee06d7bb
MD5 b8344fc5f69ff56ba60a04285fd01e9b
BLAKE2b-256 5e455118823fea9fce1187af65a8d8d58d5cc5f3fd36e88a2399981061698e1b

See more details on using hashes here.

File details

Details for the file hanjadict-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: hanjadict-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 6.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.12.13

File hashes

Hashes for hanjadict-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2b9e60e8e5553a677bd351f9e2925ddbac3160246f2cfd10f43d841c457059e4
MD5 54ac586736217b3d232da3ab5a78e20f
BLAKE2b-256 448096dd54db0f81f492672f515d9cb164cf02e695b4bf432af77033d8266f6a

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.5.0 This release

2 files

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