- Notifications
You must be signed in to change notification settings - Fork2
japanese sentence segmentation library for python
License
wwwcojp/ja_sentence_segmenter
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
日本語のテキストに対して、ルールベースによる文区切り(sentence segmentation)を行います。
- Python 3.6+
pip install ja_sentence_segmenter
importfunctoolsfromja_sentence_segmenter.common.pipelineimportmake_pipelinefromja_sentence_segmenter.concatenate.simple_concatenatorimportconcatenate_matchingfromja_sentence_segmenter.normalize.neologd_normalizerimportnormalizefromja_sentence_segmenter.split.simple_splitterimportsplit_newline,split_punctuationsplit_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)))
> ["これはペンです。", "それはマーカーです。"]
We use SemVer for versioning. For the versions available, see the tags on this repository.
TODO
MIT
テキスト正規化のコードは、mecab-ipadic-NEologdの以下のWIKIを参考に一部修正を加えています。
サンプルコードの提供者であるhideaki-t氏とoverlast氏に感謝します。
https://github.com/neologd/mecab-ipadic-neologd/wiki/Regexp.ja#python-written-by-hideaki-t--overlast
文区切りのルールとして、Pragmatic Segmenterの日本語ルールを参考にしました。
https://github.com/diasks2/pragmatic_segmenter#golden-rules-japanese
また、以下のテストコード中で用いられているテストデータを、本PJのテストコードで利用しました。
作者のKevin S. Dias氏とコントリビュータの方々に感謝します。
Thanks to Kevin S. Dias andcontributors.
About
japanese sentence segmentation library for python
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
Uh oh!
There was an error while loading.Please reload this page.