Skip to main content

kanachain

任意のバイト列を、ブロックをまたいでつながる日本語のしりとりへ可逆変換します。 符号方式は Kana Chain Block Code / 仮名チェーンブロック符号(KCBC)、 現在のフォーマット識別子は A1/D1 です。依存パッケージはありません。

pip install kanachain

CLI

kanachain serialize --text "こんにちは、KCBC"
kanachain serialize --input photo.png --output photo.kana
kanachain deserialize --input photo.kana --output restored.png
kanachain info

API

符号化と復号のメソッド名は、しりとりの「尻」にかけて serialize / deserialize としています。

from kanachain import create_kana_chain_block_code

codec = create_kana_chain_block_code()

serialized = codec.serialize("こんにちは")
print(serialized.text)
# CRC付きブロックごとに改行されたしりとり

deserialized = codec.deserialize(serialized.text)
print(deserialized.data.decode("utf-8"))  # こんにちは

strを渡すとUTF-8、UTF-16LE、それぞれのDEFLATE表現を比較し、出力語数が最少に なるものを採用します。bytesを渡した場合は任意バイナリとしてrawとDEFLATEだけを 比較します。復号結果のdataは常にbytesです。

出力の改行は正式なブロック境界ですが、改行のない単語列からも35語ごとに境界を 復元できます。復号時はひらがなとカタカナを区別しません。

同じ符号表を使うJavaScript実装(npm: kanachain)と相互運用できます。 両実装はvectors/a1d1.jsonの同じテストベクタを検証します。

仕様と辞書

フォーマット仕様、辞書の生成パイプライン、採用根拠は リポジトリにあります。

ライセンス

コードはMIT。同梱するcodebook.jsonは国立国語研究所のCC BY 4.0データに由来します。 NOTICE.mdを参照してください。

Metadata

Release files for kanachain 1.0.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 kanachain 1.0.0
File Size Uploaded Provenance
kanachain-1.0.0.tar.gz 27.1 kB Without provenance Details

Built distribution (wheel)

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

Total release size: 52.7 kB

Release files / kanachain-1.0.0.tar.gz

Download URL kanachain-1.0.0.tar.gz
Size 27.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4f20e112fb4d632963607455430ee8d26086642dc286448b7455313bcbe972e2
BLAKE2b-256 checksum
How to use checksums
63da8d0d402efffd401d49961253b61739dc266a80816f873442940a3b6231f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / kanachain-1.0.0-py3-none-any.whl

Download URL kanachain-1.0.0-py3-none-any.whl
Size 25.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2f220ca1595151b039849b933d5537f47797e5d9abd7382bb245fe8f803167fe
BLAKE2b-256 checksum
How to use checksums
86c9200f1516e8a5f76a5c4ed351edbda4660a2702afde17b16949d4f4754ce0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.6 {"installer":{"name":"uv","version":"0.12.6","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for kanachain 1.0.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

1.0.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