Repository navigation
Contributing & Adding Languages
We welcome contributions to cleave-sbd! This guide details development workflows, quality gates, and step-by-step instructions for adding support for new languages.
We use uv for fast, deterministic dependency management and virtual environments:
# 1. Clone repository
git clone https://github.com/sb-chaos/cleave-sbd.git
cd cleave-sbd
# 2. Install all development dependencies (pytest, basedpyright, ruff)
uv sync --all-groupsEvery pull request must pass the automated validation script before merging:
bash validate.shvalidate.sh automatically runs:
-
Ruff Auto-Fixes & Formatting:
uv run ruff check --fix && uv run ruff format -
Strict Lint Verification:
uv run ruff check && uv run ruff format --check -
Strict Type Checking:
uv run basedpyright(PEP 561 / strict mode with 0 errors) -
Pytest Test Suite:
uv run pytest -
Distribution Build:
uv build
cleave-sbd is engineered with strict unidirectional decoupling. Adding a new language requires zero modifications to core engine logic (segmenter.py, disambiguator.py, or models.py).
Add a new configuration file in src/csbd/language/configs/<iso_code>.toml (e.g., src/csbd/language/configs/ko.toml for Korean):
[language]
code = "ko"
name = "Korean"
replace_all_abbr_periods = false
[punctuations]
marks = ["。", "!", "?", ".", "!", "?"]
[abbreviations]
standard = [
"etc",
"co",
"inc",
]
prepositive = [
"dr",
"prof",
"mr",
"ms",
]
number = [
"no",
"vol",
"p",
]
[clean_rules]
# Optional language-specific normalization rulesAdd the language definition to src/csbd/language/lang.py under the SUPPORTED_LANGUAGES registry mapping.
Create a golden test file in tests/fixtures/golden_rules/<iso_code>.json containing language-specific test cases (abbreviations, dialogues, numbers, quotes), and verify with:
uv run pytest tests/test_languages.py -k <iso_code>When submitting changes, adhere strictly to the project's Architecture & Engineering Philosophy:
-
Zero External Runtime Dependencies: Rely solely on Python 3.11+ standard library primitives. Never add dependencies to
[project.dependencies]. -
Strict Typing (PEP 561): All new code must be fully type-annotated without untyped dictionaries (
dict[str, Any]) or implicitAny. - Layered Decoupling: Never declare data models in processing or orchestrator layers.
-
Declarative Rules: Do not write runtime lambda callbacks or dynamic regex compilations inside loops. Use immutable
Rule(pattern, replacement)tuples. -
Coordinate Invariance: Preserve 1:1 length invariance with PUA sentinels, or use
_DeltaCollectorfor normalizations.