chanoma is Characters Normalization library.文字列正規化処理用のライブラリです。
Project description
chanoma
chanoma is Characters Normalization library. 文字列正規化処理用のライブラリです。
Rust 版 の Python バインディングです。
使い方
from chanoma import Chanoma
def main():
chanoma = Chanoma(preset=True)
print(chanoma.normalize("ハンカクカナは全角カタカナに変換されます"))
if __name__ == '__main__':
main()
インストール
pip install chanoma
設定ファイル
chanoma は設定ファイルを配置することで、結果を調整することが可能です。 設定ファイルを読み込ませるための方法は二種類あります。
- 環境変数
CHANOMARC
に設定ファイルのパスを指定する。 - 以下のパスのうちのどこかにファイルを配置する。
$HOME/.config/chanoma/chanomarc.{ext}
$HOME/.config/chanoma/.chanomarc.{ext}
$HOME/chanomarc.{ext}
$HOME/.chanomarc.{ext}
$PWD/chanomarc.{ext}
$PWD/.chanomarc.{ext}
上記のどちらの場合でも、.{ext}
に指定可能な拡張子は .csv
, .yaml
(.yml
) のどれかです。
CSV ファイルの場合のフォーマット
CSV ファイルでは、一文字から一文字の置換のみ設定が可能です。 最初の列に 置換したい文字、次の列に 置換後の文字 を記述します。
from,to
&,&
YAML ファイルの場合のフォーマット
Yaml ファイルでは、一文字から一文字の置換と、Modifier を指定する二種類の方法があります。
一文字から一文字の置換
ルートキーに items
を記述し、配列指定で from
キーの値に 置換したい文字、to
キーの値に 置換後の文字 を記述します。
items:
- from: "a"
to: "A"
Modifier を指定する
ルートキーに modifiers
を記述し、一段インデントして Modifier をキーとして記述します。
指定できる Modifire は以下です。
character_converter
: 一文字から一文字の置換を設定します。キーに 置換したい文字、値に 置換後の文字 を記述します。(items
と同様の処理になります。)character_eliminator
: 指定した文字を削除します。consecutive_character_reducer
: 指定した連続する同じ文字を一つにします。dotted_space_eliminator
: 『「半角英数字」と「半角英数字」の間の半角スペース』以外の半角スペースを削除します。ligature_translator
: 指定した合字をくっつけて一文字にします。trim
: 先頭と末尾の半角スペースを削除します。neologdn
: neologdn と同様の結果になる処理をします。
modifiers:
character_converter:
a: A
b: B
character_eliminator: ["~", ∼, ∾, 〜, 〰, ~]
consecutive_character_reducer: ー
dotted_space_eliminator:
ligature_translator:
ハ゜: パ
trim:
neologdn:
Development
docker-compose build chanoma
docker-compose run --rm chanoma bash
cd /app/bindings/python3
python3 ./setup.py develop
./run-test.sh
Build
docker-compose run --rm build-wheels-for-python ./build-wheels.sh
Publish
docker-compose run --rm chanoma ./bindings/python3/publish_to_pypi.sh
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
chanoma-0.1.2.tar.gz
(4.8 kB
view hashes)
Built Distributions
Close
Hashes for chanoma-0.1.2-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2be8fb5911169d4062b60eaf4939e802fbb748694318dc32a4b4407c7ea795db |
|
MD5 | 3b30885a790b27b4c8ef1ad83f903ab4 |
|
BLAKE2b-256 | 4c5c859e5e7a31a3b857df334c4db86460a8ad55641781bab924f342d64a2b44 |
Close
Hashes for chanoma-0.1.2-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b077e36e39749635c414596f9b3b4a6d0754b61de1d504e1fcc5454fbd1f91b3 |
|
MD5 | 9d6528bd36cd057998bdc4f07c63f11a |
|
BLAKE2b-256 | e0d4e2f7d91ec87a84d1bb1fb4115ba9a7b3915dd0be307a481a851f7fdc4e11 |
Close
Hashes for chanoma-0.1.2-cp38-cp38-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 44820b74eb399a04bfbd2c9c4cfacf456a5d9d33caf090efde6c4dfaeb15e5b9 |
|
MD5 | a7db7f88c76c7fed684c4f9524af59b9 |
|
BLAKE2b-256 | d5f88e96cadf3ee08ccef9f34f4de03473526257200a664d2a93b452dd71b34d |
Close
Hashes for chanoma-0.1.2-cp37-cp37m-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6267c543f2222dacbc41ea7fb6efe1354e35f8e2accdd9afeb97058a0c54f1d |
|
MD5 | e17f58ec2770a11102383f23c652e386 |
|
BLAKE2b-256 | 3919cf5cc456eac55372dd7b37aae4e6da6edafd8404cdfda6a2e65ad1d3965d |