-
-
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
93 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Run CI | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' | ||
tags-ignore: | ||
- '**' | ||
pull_request: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: '3.12' | ||
- name: Lint by pre-commit | ||
run: | | ||
pip install pre-commit | ||
pre-commit run --all-files | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v5 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Configure venv | ||
run: | | ||
pip install uv | ||
uv venv | ||
uv pip install -r requirements-dev.lock | ||
- name: Run tests | ||
run: | | ||
source .venv/bin/activate | ||
pytest |
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
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,4 @@ | ||
extend = "../pyproject.toml" | ||
|
||
[lint] | ||
ignore = ["D100", "D103"] |
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,9 @@ | ||
<document source="<string>"> | ||
<paragraph> | ||
あなたに | ||
<word-break> | ||
寄り添う | ||
<word-break> | ||
最先端の | ||
<word-break> | ||
テクノロジー。 |
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 @@ | ||
あなたに寄り添う最先端のテクノロジー。 |
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,29 @@ | ||
from pathlib import Path | ||
from typing import List | ||
|
||
import budoux | ||
import pytest | ||
from docutils.core import publish_doctree, publish_from_doctree | ||
|
||
root = Path(__file__).parent | ||
|
||
|
||
def get_pattern_dirs() -> List[Path]: | ||
"""Return structure of folder-path as test pattern. | ||
.. note:: This is for parametrize. | ||
""" | ||
return [p for p in (root / "patterns").glob("*") if p.is_dir()] | ||
|
||
|
||
@pytest.mark.parametrize("pattern_dir", get_pattern_dirs()) | ||
def test_parse_all_sentences(pattern_dir: Path): | ||
from rst_budoux import parse_all_sentences | ||
|
||
source = pattern_dir / "source.rst" | ||
expect = pattern_dir / "pseudoxml.txt" | ||
parser = budoux.load_default_japanese_parser() | ||
document = publish_doctree(source.read_text()) | ||
document = parse_all_sentences(parser, document) | ||
result = publish_from_doctree(document, writer_name="pseudoxml").decode("utf-8") | ||
assert result == expect.read_text() |