Skip to content

Commit

Permalink
doc: Write readme by Japanese
Browse files Browse the repository at this point in the history
  • Loading branch information
attakei committed May 1, 2024
1 parent bdef936 commit 688750c
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ Text splitter in reStructuredText by BudouX.
<img src="https://github.com/attakei-lab/rst-budoux/blob/main/mv.png" >
</div>

.. note::

`日本語での説明があります。 <https://github.com/attakei-lab/rst-budoux/blob/main/README_ja.rst> `_

Example
=======

Expand Down
116 changes: 116 additions & 0 deletions README_ja.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
==========
rst-budoux
==========

reStructuredTextのテキストを分かち書きするライブラリです。

.. raw:: html

<div align="center">
<img src="https://github.com/attakei-lab/rst-budoux/blob/main/mv.png" >
</div>

概要
====

reStructuredTextをパースしたdoctreeに手を加えて、日本語文を分かち書きされた状態に変換します。

具体的には
----------

このようなreStructuredTextのソースを用意します。

.. code:: rst
Example from BudouX
===================
あなたに寄り添う最先端のテクノロジー。
docutilsの ``rst2pseudoxml`` を使うと、内部ではこのような構成としてパースしていることが分かります。

.. code:: console
$ run rst2pseudoxml examples/budoux-sample-text.rst
<document ids="example-from-budoux" names="example\ from\ budoux" source="examples/budoux-sample-text.rst" title="Example from BudouX">
<title>
Example from BudouX
<paragraph>
あなたに寄り添う最先端のテクノロジー。
``rst-budoux`` を用いた ``rst-budoux2pseudoxml`` を使うと、分かち書きを行った下記のような構成に編集します。

.. code:: console
$ run rst-budoux2pseudoxml examples/budoux-sample-text.rst
<document ids="example-from-budoux" names="example\ from\ budoux" source="examples/budoux-sample-text.rst" title="Example from BudouX">
<title>
Example from BudouX
<paragraph>
あなたに
<word-break>
寄り添う
<word-break>
最先端の
<word-break>
テクノロジー。
機能
====

コア機能としては、
「BudouXのパーサーに従ってテキストを分かち書きされた状態に分割する」
「分割された間に【区切り可能】であることを示すノードの挿入する」
という2点のみです。

もちろん、自身を含めてこれだけだと不便ではあるため、次のものを同梱しています。

* 動作を参照可能にするCLIツール。
* Sphinx拡張。

使い方
======

.. note:: ここは予定を書いています。

インストール
------------

.. code:: console
pip install rst-budoux
ライブラリとしての利用法
------------------------

.. code:: python
import budoux
from rst_budoux import parse_all_sentences
document = func(...)
# docutilsのdoctreeを生成するコードからdoctreeを受け取った後の実装例
parser = budoux.load_default_japanese_parser()
document = parse_all_sentences(parser, document)
...
Sphinxを経由しての利用例
------------------------

.. code:: python
extensions = [
...,
"rst_budoux.sphinx",
]
budoux_html_separator = "<wbr>"
buxoux_html_append_style = """
body {
word-break: keep-all;
overflow-wrap: anywhere;
}
"""

0 comments on commit 688750c

Please sign in to comment.