Skip to main content

Recursive atomic decomposition of CJK characters with 9-grid spatial encoding

Project description

cjk-semantic-split

Recursive atomic decomposition of CJK characters with 9-grid spatial position encoding.

pip install cjk-semantic-split
from chinese_decompose import decompose

decompose("踩")
# '踩 [30]:足 [60]:爪 [80]:木'

decompose("囚")
# '囚 [90]:囗 [0]:人'

decompose("踩好", as_tree=True)
# [DecompositionTree('踩'), DecompositionTree('好')]

# Read the full structural decomposition (preserves intermediate nodes
# like 采 inside 踩; each tree node carries its 2-digit position code).
from chinese_decompose import read_structure
trees = read_structure("踩")
trees[0].atoms     # ('足', '爪', '木')
trees[0].positions # (30, 60, 80)
trees[0].children[1].char  # '采'  (intermediate node preserved!)
trees[0].children[1].position  # 40

Documentation

  • Component Position Encoding — full position-code reference (00/10/20/30/40, corners, 4-cell strips, surrounds) and the composition operator.
  • Decomposition Logic — algorithm walkthrough, data flow, worked example 踩 → 足 + 采 → 爪 + 木.

Position Encoding

Every component sits at a 2-digit position code: cardinals (10/20/30/40), single-cell corners (50/60/70/80), 4-cell layout strips (14/16/34/36), or surround envelopes (9099). See the design spec for full details.

CLI

python -m chinese_decompose                   # JSON output (default)
python -m chinese_decompose  --format dsl    # DSL string
python -m chinese_decompose  --format tree   # repr() of nested trees
python -m chinese_decompose --self-test         # coverage report

Data Sources

Decomposition data is bundled for offline use. Coverage extends across four tiers:

  • Tier 1 (Unihan kIDS): ~21k chars
  • Tier 2 (wikimedia Commons): ~22k chars
  • Tier 3 (next-layer harvest): ~80k chars
  • Tier 4 (manual patches): dispute-case overrides

Last-wins resolution: patches > l3 > l2 > l1.

Configuration

from chinese_decompose import set_primitives

set_primitives({"木", "火", "水", ...})  # process-local override

License

MIT — see LICENSE.

Project details


Download files

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

Source Distribution

cjk_semantic_split-0.1.1.tar.gz (95.0 kB view details)

Uploaded Source

Built Distribution

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

cjk_semantic_split-0.1.1-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file cjk_semantic_split-0.1.1.tar.gz.

File metadata

  • Download URL: cjk_semantic_split-0.1.1.tar.gz
  • Upload date:
  • Size: 95.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.11

File hashes

Hashes for cjk_semantic_split-0.1.1.tar.gz
Algorithm Hash digest
SHA256 62842614fcd33644c9eb024b8093dcb98481e59fbd1ce30b39dffe4f418c8afe
MD5 80f95467e995c9a058b3c106b2e971a5
BLAKE2b-256 951b38bdf24c3409bbb40dac64b3455f510411938f65c748b004397480a0f013

See more details on using hashes here.

File details

Details for the file cjk_semantic_split-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for cjk_semantic_split-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 dbae2548f3b54be2ee885d5d03de780910af9d3b112206fadaa209e37f1d44e0
MD5 7fb6b8991796e8521c3c9039463ac977
BLAKE2b-256 34460586734587aa8a7fc22d66ebbefabaaa601a31d215b5f7ede0783debef74

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page