sentence segmenter for japanese text
Project description
ja_sentence_segmenter
日本語のテキストに対して、ルールベースによる文区切り(sentence segmentation)を行います。
Getting Started
Prerequisites
- Python 3.6+
Installing
pip install ja_sentence_segmenter
Usage
import functools
from ja_sentence_segmenter.common.pipeline import make_pipeline
from ja_sentence_segmenter.concatenate.simple_concatenator import concatenate_matching
from ja_sentence_segmenter.normalize.neologd_normalizer import normalize
from ja_sentence_segmenter.split.simple_splitter import split_newline, split_punctuation
split_punc2 = functools.partial(split_punctuation, punctuations=r"。!?")
concat_tail_no = functools.partial(concatenate_matching, former_matching_rule=r"^(?P<result>.+)(の)$", remove_former_matched=False)
segmenter = make_pipeline(normalize, split_newline, concat_tail_no, split_punc2)
# Golden Rule: Simple period to end sentence #001 (from https://github.com/diasks2/pragmatic_segmenter/blob/master/spec/pragmatic_segmenter/languages/japanese_spec.rb#L6)
text1 = "これはペンです。それはマーカーです。"
print(list(segmenter(text1)))
> ["これはペンです。", "それはマーカーです。"]
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Contributing
TODO
License
MIT
Acknowledgments
テキストの正規化処理
テキスト正規化のコードは、mecab-ipadic-NEologdの以下のWIKIを参考に一部修正を加えています。
サンプルコードの提供者であるhideaki-t氏とoverlast氏に感謝します。
https://github.com/neologd/mecab-ipadic-neologd/wiki/Regexp.ja#python-written-by-hideaki-t--overlast
文区切り(sentence segmentation)のルール
文区切りのルールとして、Pragmatic Segmenterの日本語ルールを参考にしました。
https://github.com/diasks2/pragmatic_segmenter#golden-rules-japanese
また、以下のテストコード中で用いられているテストデータを、本PJのテストコードで利用しました。
作者のKevin S. Dias氏とコントリビュータの方々に感謝します。
Thanks to Kevin S. Dias and contributors.
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
Built Distribution
Hashes for ja_sentence_segmenter-0.0.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e22b5685947bbb201333f3f1d497bd82cd350a2393c8f34ee1b98da910c13bff |
|
MD5 | 789c38b0cd2d0455c2a0e85bfed62f70 |
|
BLAKE2b-256 | 86d664f880b33c95d21fe4a1b483a90f0b0f94bdfb7b7944ac0fdc766c6c062c |
Hashes for ja_sentence_segmenter-0.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29c441ff99d5fbcb9f455d668b09007e0f39d9fe4f459b943b6119c84bbf50e0 |
|
MD5 | d2422302bfd713117dedb51d17208e3c |
|
BLAKE2b-256 | 01f4c446e911270773c8497a4edd2c902df612b3179327d170205f56f919d8c4 |