-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
165 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
========== | ||
Components | ||
========== | ||
|
||
Index of toybox components that are used in ``conf.py`` directly. | ||
Subpages have overview, usage and **demo**. | ||
|
||
.. toctree:: | ||
:maxdepth: 1 | ||
:glob: | ||
|
||
*/index |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
============================== | ||
atsphinx.toybox.lindera_search | ||
============================== | ||
|
||
.. note:: Added by v2024.12.10 | ||
|
||
Overview | ||
======== | ||
|
||
This is to use Lindera search components of Sphinx. | ||
|
||
Usage | ||
===== | ||
|
||
Install requires | ||
---------------- | ||
|
||
This extension requires optional installation. | ||
Please add 'lindera-search' option when you install it. | ||
|
||
.. code-block:: console | ||
pip install 'atsphinx-toybox[lindera-search]' | ||
Set configuration | ||
----------------- | ||
|
||
Add this into your ``conf.py`` of Sphinx. | ||
|
||
.. code-block:: python | ||
:caption: conf.py | ||
html_search_options = { | ||
"type": "atsphinx.toybox.lindera_search.LinderaSplitter", | ||
} | ||
Demo | ||
==== | ||
|
||
.. todo: Write it. | ||
Refs | ||
==== | ||
|
||
* `lindera-py <https://pypi.org/project/lindera-py/>`_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,5 @@ This is attakei's alpha-level Sphinx-extensions. | |
|
||
guide | ||
extensions/index | ||
components/index | ||
changes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
"""Tokenize override by Lindera.""" | ||
|
||
from lindera_py import Segmenter, Tokenizer, load_dictionary | ||
from sphinx.search.ja import BaseSplitter | ||
|
||
|
||
class LinderaSplitter(BaseSplitter): | ||
"""Simple splitter class using Lindera as tokeniser.""" | ||
|
||
def __init__(self, options: dict[str, str]) -> None: # noqa: D107 | ||
self.dictionary = load_dictionary("ipadic") | ||
self.segmenter = Segmenter("normal", self.dictionary) | ||
self.tokenizer = Tokenizer(self.segmenter) | ||
|
||
def split(self, input: str) -> list[str]: # noqa: D102 | ||
return [token.text for token in self.tokenizer(input)] |