phrasplit 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- phrasplit-0.1.0/.github/pytest.ini +3 -0
- phrasplit-0.1.0/.github/workflows/codecov.yml +29 -0
- phrasplit-0.1.0/.github/workflows/pre-commit.yml +13 -0
- phrasplit-0.1.0/.github/workflows/python-publish.yml +39 -0
- phrasplit-0.1.0/.github/workflows/tests.yml +23 -0
- phrasplit-0.1.0/.gitignore +208 -0
- phrasplit-0.1.0/.pre-commit-config.yaml +66 -0
- phrasplit-0.1.0/.prettierrc.yml +8 -0
- phrasplit-0.1.0/.readthedocs.yaml +22 -0
- phrasplit-0.1.0/.ruff.toml +29 -0
- phrasplit-0.1.0/LICENSE +21 -0
- phrasplit-0.1.0/PKG-INFO +227 -0
- phrasplit-0.1.0/README.md +177 -0
- phrasplit-0.1.0/docs/api.rst +108 -0
- phrasplit-0.1.0/docs/cli.rst +180 -0
- phrasplit-0.1.0/docs/conf.py +89 -0
- phrasplit-0.1.0/docs/examples.rst +256 -0
- phrasplit-0.1.0/docs/index.rst +72 -0
- phrasplit-0.1.0/docs/installation.rst +73 -0
- phrasplit-0.1.0/docs/make.bat +113 -0
- phrasplit-0.1.0/docs/make.py +83 -0
- phrasplit-0.1.0/docs/requirements.txt +3 -0
- phrasplit-0.1.0/docs/usage.rst +164 -0
- phrasplit-0.1.0/phrasplit/__init__.py +21 -0
- phrasplit-0.1.0/phrasplit/_version.py +34 -0
- phrasplit-0.1.0/phrasplit/cli.py +207 -0
- phrasplit-0.1.0/phrasplit/py.typed +0 -0
- phrasplit-0.1.0/phrasplit/splitter.py +345 -0
- phrasplit-0.1.0/phrasplit.egg-info/PKG-INFO +227 -0
- phrasplit-0.1.0/phrasplit.egg-info/SOURCES.txt +38 -0
- phrasplit-0.1.0/phrasplit.egg-info/dependency_links.txt +1 -0
- phrasplit-0.1.0/phrasplit.egg-info/entry_points.txt +2 -0
- phrasplit-0.1.0/phrasplit.egg-info/requires.txt +7 -0
- phrasplit-0.1.0/phrasplit.egg-info/top_level.txt +1 -0
- phrasplit-0.1.0/pyproject.toml +158 -0
- phrasplit-0.1.0/requirements-test.txt +9 -0
- phrasplit-0.1.0/setup.cfg +4 -0
- phrasplit-0.1.0/setup.py +6 -0
- phrasplit-0.1.0/tests/__init__.py +0 -0
- phrasplit-0.1.0/tests/test_splitter.py +352 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
name: CodeCov
|
|
2
|
+
on: push
|
|
3
|
+
jobs:
|
|
4
|
+
run:
|
|
5
|
+
runs-on: ubuntu-latest
|
|
6
|
+
env:
|
|
7
|
+
OS: ubuntu-latest
|
|
8
|
+
steps:
|
|
9
|
+
- uses: actions/checkout@master
|
|
10
|
+
- name: Setup Python
|
|
11
|
+
uses: actions/setup-python@master
|
|
12
|
+
- name: 'generate report'
|
|
13
|
+
run: |
|
|
14
|
+
pip install coverage click pytest pytest-cov
|
|
15
|
+
pip install -r requirements-test.txt
|
|
16
|
+
pip install spacy
|
|
17
|
+
python -m spacy download en_core_web_sm
|
|
18
|
+
pip install -e .
|
|
19
|
+
pytest --cov --junitxml=junit.xml
|
|
20
|
+
- name: Upload coverage to Codecov
|
|
21
|
+
uses: codecov/codecov-action@v5
|
|
22
|
+
with:
|
|
23
|
+
token: ${{ secrets.CODECOV_TOKEN }} # required
|
|
24
|
+
- name: Upload test results to Codecov
|
|
25
|
+
if: ${{ !cancelled() }}
|
|
26
|
+
uses: codecov/test-results-action@v1
|
|
27
|
+
with:
|
|
28
|
+
token: ${{ secrets.CODECOV_TOKEN }}
|
|
29
|
+
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# This workflow will upload a Python Package using Twine when a release is created
|
|
2
|
+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python#publishing-to-package-registries
|
|
3
|
+
|
|
4
|
+
# This workflow uses actions that are not certified by GitHub.
|
|
5
|
+
# They are provided by a third-party and are governed by
|
|
6
|
+
# separate terms of service, privacy policy, and support
|
|
7
|
+
# documentation.
|
|
8
|
+
|
|
9
|
+
name: Upload Python Package
|
|
10
|
+
|
|
11
|
+
on:
|
|
12
|
+
release:
|
|
13
|
+
types: [published]
|
|
14
|
+
|
|
15
|
+
permissions:
|
|
16
|
+
contents: read
|
|
17
|
+
|
|
18
|
+
jobs:
|
|
19
|
+
deploy:
|
|
20
|
+
|
|
21
|
+
runs-on: ubuntu-latest
|
|
22
|
+
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@v3
|
|
25
|
+
- name: Set up Python
|
|
26
|
+
uses: actions/setup-python@v3
|
|
27
|
+
with:
|
|
28
|
+
python-version: '3.x'
|
|
29
|
+
- name: Install dependencies
|
|
30
|
+
run: |
|
|
31
|
+
python -m pip install --upgrade pip
|
|
32
|
+
pip install build
|
|
33
|
+
- name: Build package
|
|
34
|
+
run: python -m build
|
|
35
|
+
- name: Publish package
|
|
36
|
+
uses: pypa/gh-action-pypi-publish@27b31702a0e7fc50959f5ad993c78deac1bdfc29
|
|
37
|
+
with:
|
|
38
|
+
user: __token__
|
|
39
|
+
password: ${{ secrets.PYPI_API_TOKEN }}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
name: Run tests
|
|
2
|
+
on: [push]
|
|
3
|
+
jobs:
|
|
4
|
+
run:
|
|
5
|
+
runs-on: ${{ matrix.os }}
|
|
6
|
+
strategy:
|
|
7
|
+
matrix:
|
|
8
|
+
os: [ubuntu-latest, windows-latest, macos-latest]
|
|
9
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
10
|
+
steps:
|
|
11
|
+
- uses: actions/checkout@master
|
|
12
|
+
- name: Setup Python
|
|
13
|
+
uses: actions/setup-python@master
|
|
14
|
+
with:
|
|
15
|
+
python-version: ${{ matrix.python-version }}
|
|
16
|
+
- name: Install packages
|
|
17
|
+
run: |
|
|
18
|
+
pip install pytest
|
|
19
|
+
pip install -e .
|
|
20
|
+
pip install -r requirements-test.txt
|
|
21
|
+
pip install spacy
|
|
22
|
+
python -m spacy download en_core_web_sm
|
|
23
|
+
pytest
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[codz]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# C extensions
|
|
7
|
+
*.so
|
|
8
|
+
|
|
9
|
+
# Distribution / packaging
|
|
10
|
+
.Python
|
|
11
|
+
build/
|
|
12
|
+
develop-eggs/
|
|
13
|
+
dist/
|
|
14
|
+
downloads/
|
|
15
|
+
eggs/
|
|
16
|
+
.eggs/
|
|
17
|
+
lib/
|
|
18
|
+
lib64/
|
|
19
|
+
parts/
|
|
20
|
+
sdist/
|
|
21
|
+
var/
|
|
22
|
+
wheels/
|
|
23
|
+
share/python-wheels/
|
|
24
|
+
*.egg-info/
|
|
25
|
+
.installed.cfg
|
|
26
|
+
*.egg
|
|
27
|
+
MANIFEST
|
|
28
|
+
|
|
29
|
+
# PyInstaller
|
|
30
|
+
# Usually these files are written by a python script from a template
|
|
31
|
+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
|
32
|
+
*.manifest
|
|
33
|
+
*.spec
|
|
34
|
+
|
|
35
|
+
# Installer logs
|
|
36
|
+
pip-log.txt
|
|
37
|
+
pip-delete-this-directory.txt
|
|
38
|
+
|
|
39
|
+
# Unit test / coverage reports
|
|
40
|
+
htmlcov/
|
|
41
|
+
.tox/
|
|
42
|
+
.nox/
|
|
43
|
+
.coverage
|
|
44
|
+
.coverage.*
|
|
45
|
+
.cache
|
|
46
|
+
nosetests.xml
|
|
47
|
+
coverage.xml
|
|
48
|
+
*.cover
|
|
49
|
+
*.py.cover
|
|
50
|
+
.hypothesis/
|
|
51
|
+
.pytest_cache/
|
|
52
|
+
cover/
|
|
53
|
+
|
|
54
|
+
# Translations
|
|
55
|
+
*.mo
|
|
56
|
+
*.pot
|
|
57
|
+
|
|
58
|
+
# Django stuff:
|
|
59
|
+
*.log
|
|
60
|
+
local_settings.py
|
|
61
|
+
db.sqlite3
|
|
62
|
+
db.sqlite3-journal
|
|
63
|
+
|
|
64
|
+
# Flask stuff:
|
|
65
|
+
instance/
|
|
66
|
+
.webassets-cache
|
|
67
|
+
|
|
68
|
+
# Scrapy stuff:
|
|
69
|
+
.scrapy
|
|
70
|
+
|
|
71
|
+
# Sphinx documentation
|
|
72
|
+
docs/_build/
|
|
73
|
+
|
|
74
|
+
# PyBuilder
|
|
75
|
+
.pybuilder/
|
|
76
|
+
target/
|
|
77
|
+
|
|
78
|
+
# Jupyter Notebook
|
|
79
|
+
.ipynb_checkpoints
|
|
80
|
+
|
|
81
|
+
# IPython
|
|
82
|
+
profile_default/
|
|
83
|
+
ipython_config.py
|
|
84
|
+
|
|
85
|
+
# pyenv
|
|
86
|
+
# For a library or package, you might want to ignore these files since the code is
|
|
87
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
88
|
+
# .python-version
|
|
89
|
+
|
|
90
|
+
# pipenv
|
|
91
|
+
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
|
92
|
+
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
|
93
|
+
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
|
94
|
+
# install all needed dependencies.
|
|
95
|
+
#Pipfile.lock
|
|
96
|
+
|
|
97
|
+
# UV
|
|
98
|
+
# Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
|
|
99
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
100
|
+
# commonly ignored for libraries.
|
|
101
|
+
#uv.lock
|
|
102
|
+
|
|
103
|
+
# poetry
|
|
104
|
+
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
|
|
105
|
+
# This is especially recommended for binary packages to ensure reproducibility, and is more
|
|
106
|
+
# commonly ignored for libraries.
|
|
107
|
+
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
|
|
108
|
+
#poetry.lock
|
|
109
|
+
#poetry.toml
|
|
110
|
+
|
|
111
|
+
# pdm
|
|
112
|
+
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
|
|
113
|
+
# pdm recommends including project-wide configuration in pdm.toml, but excluding .pdm-python.
|
|
114
|
+
# https://pdm-project.org/en/latest/usage/project/#working-with-version-control
|
|
115
|
+
#pdm.lock
|
|
116
|
+
#pdm.toml
|
|
117
|
+
.pdm-python
|
|
118
|
+
.pdm-build/
|
|
119
|
+
|
|
120
|
+
# pixi
|
|
121
|
+
# Similar to Pipfile.lock, it is generally recommended to include pixi.lock in version control.
|
|
122
|
+
#pixi.lock
|
|
123
|
+
# Pixi creates a virtual environment in the .pixi directory, just like venv module creates one
|
|
124
|
+
# in the .venv directory. It is recommended not to include this directory in version control.
|
|
125
|
+
.pixi
|
|
126
|
+
|
|
127
|
+
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
|
|
128
|
+
__pypackages__/
|
|
129
|
+
|
|
130
|
+
# Celery stuff
|
|
131
|
+
celerybeat-schedule
|
|
132
|
+
celerybeat.pid
|
|
133
|
+
|
|
134
|
+
# SageMath parsed files
|
|
135
|
+
*.sage.py
|
|
136
|
+
|
|
137
|
+
# Environments
|
|
138
|
+
.env
|
|
139
|
+
.envrc
|
|
140
|
+
.venv
|
|
141
|
+
env/
|
|
142
|
+
venv/
|
|
143
|
+
ENV/
|
|
144
|
+
env.bak/
|
|
145
|
+
venv.bak/
|
|
146
|
+
|
|
147
|
+
# Spyder project settings
|
|
148
|
+
.spyderproject
|
|
149
|
+
.spyproject
|
|
150
|
+
|
|
151
|
+
# Rope project settings
|
|
152
|
+
.ropeproject
|
|
153
|
+
|
|
154
|
+
# mkdocs documentation
|
|
155
|
+
/site
|
|
156
|
+
|
|
157
|
+
# mypy
|
|
158
|
+
.mypy_cache/
|
|
159
|
+
.dmypy.json
|
|
160
|
+
dmypy.json
|
|
161
|
+
|
|
162
|
+
# Pyre type checker
|
|
163
|
+
.pyre/
|
|
164
|
+
|
|
165
|
+
# pytype static type analyzer
|
|
166
|
+
.pytype/
|
|
167
|
+
|
|
168
|
+
# Cython debug symbols
|
|
169
|
+
cython_debug/
|
|
170
|
+
|
|
171
|
+
# PyCharm
|
|
172
|
+
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
|
|
173
|
+
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
|
|
174
|
+
# and can be added to the global gitignore or merged into this file. For a more nuclear
|
|
175
|
+
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
|
|
176
|
+
#.idea/
|
|
177
|
+
|
|
178
|
+
# Abstra
|
|
179
|
+
# Abstra is an AI-powered process automation framework.
|
|
180
|
+
# Ignore directories containing user credentials, local state, and settings.
|
|
181
|
+
# Learn more at https://abstra.io/docs
|
|
182
|
+
.abstra/
|
|
183
|
+
|
|
184
|
+
# Visual Studio Code
|
|
185
|
+
# Visual Studio Code specific template is maintained in a separate VisualStudioCode.gitignore
|
|
186
|
+
# that can be found at https://github.com/github/gitignore/blob/main/Global/VisualStudioCode.gitignore
|
|
187
|
+
# and can be added to the global gitignore or merged into this file. However, if you prefer,
|
|
188
|
+
# you could uncomment the following to ignore the entire vscode folder
|
|
189
|
+
# .vscode/
|
|
190
|
+
|
|
191
|
+
# Ruff stuff:
|
|
192
|
+
.ruff_cache/
|
|
193
|
+
|
|
194
|
+
# PyPI configuration file
|
|
195
|
+
.pypirc
|
|
196
|
+
|
|
197
|
+
# Cursor
|
|
198
|
+
# Cursor is an AI-powered code editor. `.cursorignore` specifies files/directories to
|
|
199
|
+
# exclude from AI features like autocomplete and code analysis. Recommended for sensitive data
|
|
200
|
+
# refer to https://docs.cursor.com/context/ignore-files
|
|
201
|
+
.cursorignore
|
|
202
|
+
.cursorindexingignore
|
|
203
|
+
|
|
204
|
+
# Marimo
|
|
205
|
+
marimo/_static/
|
|
206
|
+
marimo/_lsp/
|
|
207
|
+
__marimo__/
|
|
208
|
+
phrasplit/_version.py
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
exclude: |
|
|
2
|
+
# NOT INSTALLABLE ADDONS
|
|
3
|
+
# END NOT INSTALLABLE ADDONS
|
|
4
|
+
# Files and folders generated by bots, to avoid loops
|
|
5
|
+
^setup/|/static/description/index\.html$|
|
|
6
|
+
# We don't want to mess with tool-generated files
|
|
7
|
+
.svg$|/tests/([^/]+/)?cassettes/|^.copier-answers.yml$|^.github/|
|
|
8
|
+
# Maybe reactivate this when all README files include prettier ignore tags?
|
|
9
|
+
^README\.md$|
|
|
10
|
+
# Repos using Sphinx to generate docs don't need prettying
|
|
11
|
+
^docs/_templates/.*\.html$|
|
|
12
|
+
# Don't bother non-technical authors with formatting issues in docs
|
|
13
|
+
readme/.*\.(rst|md)$|
|
|
14
|
+
# Ignore build and dist directories in addons
|
|
15
|
+
/build/|/dist/|/dev/|/notebooks/
|
|
16
|
+
# You don't usually want a bot to modify your legal texts
|
|
17
|
+
(LICENSE.*|COPYING.*)|
|
|
18
|
+
default_language_version:
|
|
19
|
+
python: python3
|
|
20
|
+
node: "16.17.0"
|
|
21
|
+
repos:
|
|
22
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
23
|
+
rev: v0.6.8
|
|
24
|
+
hooks:
|
|
25
|
+
- id: ruff
|
|
26
|
+
args: [--fix, --exit-non-zero-on-fix, --config=.ruff.toml]
|
|
27
|
+
- id: ruff-format
|
|
28
|
+
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
29
|
+
rev: v4.6.0
|
|
30
|
+
hooks:
|
|
31
|
+
- id: check-toml
|
|
32
|
+
- id: check-yaml
|
|
33
|
+
- id: end-of-file-fixer
|
|
34
|
+
- id: trailing-whitespace
|
|
35
|
+
- id: check-symlinks
|
|
36
|
+
- id: check-xml
|
|
37
|
+
- id: mixed-line-ending
|
|
38
|
+
args: ["--fix=lf"]
|
|
39
|
+
- id: debug-statements
|
|
40
|
+
- id: fix-encoding-pragma
|
|
41
|
+
args: ["--remove"]
|
|
42
|
+
- id: check-case-conflict
|
|
43
|
+
- id: check-docstring-first
|
|
44
|
+
- id: check-executables-have-shebangs
|
|
45
|
+
- id: check-merge-conflict
|
|
46
|
+
# exclude files where underlines are not distinguishable from merge conflicts
|
|
47
|
+
exclude: /README\.rst$|^docs/.*\.rst$
|
|
48
|
+
- repo: https://github.com/pre-commit/mirrors-prettier
|
|
49
|
+
rev: v2.7.1
|
|
50
|
+
hooks:
|
|
51
|
+
- id: prettier
|
|
52
|
+
name: prettier (with plugin-xml)
|
|
53
|
+
additional_dependencies:
|
|
54
|
+
- "prettier@2.7.1"
|
|
55
|
+
- "@prettier/plugin-xml@2.2.0"
|
|
56
|
+
args:
|
|
57
|
+
- --plugin=@prettier/plugin-xml
|
|
58
|
+
files: \.(css|htm|html|js|json|jsx|less|md|scss|toml|ts|xml|yaml|yml)$
|
|
59
|
+
- repo: https://github.com/pre-commit/mirrors-eslint
|
|
60
|
+
rev: v8.24.0
|
|
61
|
+
hooks:
|
|
62
|
+
- id: eslint
|
|
63
|
+
verbose: true
|
|
64
|
+
args:
|
|
65
|
+
- --color
|
|
66
|
+
- --fix
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Read the Docs configuration file
|
|
2
|
+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
|
|
3
|
+
|
|
4
|
+
# Required
|
|
5
|
+
version: 2
|
|
6
|
+
|
|
7
|
+
# Set the OS, Python version, and other tools you might need
|
|
8
|
+
build:
|
|
9
|
+
os: ubuntu-24.04
|
|
10
|
+
tools:
|
|
11
|
+
python: "3.13"
|
|
12
|
+
|
|
13
|
+
# Build documentation in the "docs/" directory with Sphinx
|
|
14
|
+
sphinx:
|
|
15
|
+
configuration: docs/conf.py
|
|
16
|
+
|
|
17
|
+
# Optionally, but recommended,
|
|
18
|
+
# declare the Python requirements required to build your documentation
|
|
19
|
+
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
|
|
20
|
+
python:
|
|
21
|
+
install:
|
|
22
|
+
- requirements: docs/requirements.txt
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
|
|
2
|
+
target-version = "py39"
|
|
3
|
+
fix = true
|
|
4
|
+
|
|
5
|
+
[lint]
|
|
6
|
+
extend-select = [
|
|
7
|
+
"B",
|
|
8
|
+
"C90",
|
|
9
|
+
"E501", # line too long (default 88)
|
|
10
|
+
"I", # isort
|
|
11
|
+
"UP", # pyupgrade
|
|
12
|
+
]
|
|
13
|
+
exclude = ["setup/*", "notebooks/*"]
|
|
14
|
+
|
|
15
|
+
[format]
|
|
16
|
+
exclude = ["setup/*", "notebooks/*"]
|
|
17
|
+
|
|
18
|
+
[lint.per-file-ignores]
|
|
19
|
+
"__init__.py" = ["F401", "I001"] # ignore unused and unsorted imports in __init__.py
|
|
20
|
+
"__manifest__.py" = ["B018"] # useless expression
|
|
21
|
+
"cli.py" = ["C901"] # Allow higher complexity for CLI commands with recursive logic
|
|
22
|
+
"pydrime/cli/*.py" = ["C901"] # Allow higher complexity for CLI command modules
|
|
23
|
+
"test_webdav_provider.py" = ["I001"] # wsgidav requires specific import order to avoid circular import
|
|
24
|
+
|
|
25
|
+
[lint.isort]
|
|
26
|
+
section-order = ["future", "standard-library", "third-party", "first-party", "local-folder"]
|
|
27
|
+
|
|
28
|
+
[lint.mccabe]
|
|
29
|
+
max-complexity = 22
|
phrasplit-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Holger Nahrstaedt
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
phrasplit-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: phrasplit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: A simple tool to split text.
|
|
5
|
+
Author-email: Holger Nahrstaedt <nahrstaedt@gmail.com>
|
|
6
|
+
License: MIT License
|
|
7
|
+
|
|
8
|
+
Copyright (c) 2025 Holger Nahrstaedt
|
|
9
|
+
|
|
10
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
11
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
12
|
+
in the Software without restriction, including without limitation the rights
|
|
13
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
14
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
15
|
+
furnished to do so, subject to the following conditions:
|
|
16
|
+
|
|
17
|
+
The above copyright notice and this permission notice shall be included in all
|
|
18
|
+
copies or substantial portions of the Software.
|
|
19
|
+
|
|
20
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
21
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
22
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
23
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
24
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
25
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
26
|
+
SOFTWARE.
|
|
27
|
+
|
|
28
|
+
Project-URL: Homepage, https://github.com/holgern/phrasplit
|
|
29
|
+
Classifier: Intended Audience :: Developers
|
|
30
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
31
|
+
Classifier: Operating System :: OS Independent
|
|
32
|
+
Classifier: Programming Language :: Python :: 3
|
|
33
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
34
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
35
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
39
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
40
|
+
Requires-Python: >=3.9
|
|
41
|
+
Description-Content-Type: text/markdown
|
|
42
|
+
License-File: LICENSE
|
|
43
|
+
Requires-Dist: click>=8.0.0
|
|
44
|
+
Requires-Dist: rich>=13.0.0
|
|
45
|
+
Requires-Dist: spacy>=3.5.0
|
|
46
|
+
Provides-Extra: dev
|
|
47
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
48
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
49
|
+
Dynamic: license-file
|
|
50
|
+
|
|
51
|
+
# phrasplit
|
|
52
|
+
|
|
53
|
+
A Python library for splitting text into sentences, clauses, or paragraphs using spaCy
|
|
54
|
+
NLP. Designed for audiobook creation and text-to-speech processing.
|
|
55
|
+
|
|
56
|
+
## Features
|
|
57
|
+
|
|
58
|
+
- **Sentence splitting**: Intelligent sentence boundary detection using spaCy
|
|
59
|
+
- **Clause splitting**: Split sentences at commas for natural pause points
|
|
60
|
+
- **Paragraph splitting**: Split text at double newlines
|
|
61
|
+
- **Long line splitting**: Break long lines at sentence/clause boundaries
|
|
62
|
+
- **Abbreviation handling**: Correctly handles Mr., Dr., U.S.A., etc.
|
|
63
|
+
- **Ellipsis support**: Preserves ellipses without incorrect splitting
|
|
64
|
+
|
|
65
|
+
## Installation
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
pip install phrasplit
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
You'll also need to download a spaCy language model:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
python -m spacy download en_core_web_sm
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Quick Start
|
|
78
|
+
|
|
79
|
+
### Python API
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
from phrasplit import split_sentences, split_clauses, split_paragraphs, split_long_lines
|
|
83
|
+
|
|
84
|
+
# Split text into sentences
|
|
85
|
+
text = "Dr. Smith is here. She has a Ph.D. in Chemistry."
|
|
86
|
+
sentences = split_sentences(text)
|
|
87
|
+
# ['Dr. Smith is here.', 'She has a Ph.D. in Chemistry.']
|
|
88
|
+
|
|
89
|
+
# Split sentences into comma-separated parts (for audiobook pauses)
|
|
90
|
+
text = "I like coffee, and I like tea."
|
|
91
|
+
clauses = split_clauses(text)
|
|
92
|
+
# ['I like coffee,', 'and I like tea.']
|
|
93
|
+
|
|
94
|
+
# Split text into paragraphs
|
|
95
|
+
text = "First paragraph.\n\nSecond paragraph."
|
|
96
|
+
paragraphs = split_paragraphs(text)
|
|
97
|
+
# ['First paragraph.', 'Second paragraph.']
|
|
98
|
+
|
|
99
|
+
# Split long lines at natural boundaries
|
|
100
|
+
text = "This is a very long sentence that needs to be split."
|
|
101
|
+
lines = split_long_lines(text, max_length=30)
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Command Line Interface
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
# Split into sentences
|
|
108
|
+
phrasplit sentences input.txt -o output.txt
|
|
109
|
+
|
|
110
|
+
# Split into clauses
|
|
111
|
+
phrasplit clauses input.txt -o output.txt
|
|
112
|
+
|
|
113
|
+
# Split into paragraphs
|
|
114
|
+
phrasplit paragraphs input.txt -o output.txt
|
|
115
|
+
|
|
116
|
+
# Split long lines (default max 80 characters)
|
|
117
|
+
phrasplit longlines input.txt -o output.txt --max-length 60
|
|
118
|
+
|
|
119
|
+
# Use a different spaCy model
|
|
120
|
+
phrasplit sentences input.txt --model en_core_web_lg
|
|
121
|
+
|
|
122
|
+
# Read from stdin (pipe or redirect)
|
|
123
|
+
echo "Hello world. This is a test." | phrasplit sentences
|
|
124
|
+
cat input.txt | phrasplit clauses -o output.txt
|
|
125
|
+
|
|
126
|
+
# Explicit stdin with dash
|
|
127
|
+
phrasplit sentences - < input.txt
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## API Reference
|
|
131
|
+
|
|
132
|
+
### `split_sentences(text, language_model="en_core_web_sm")`
|
|
133
|
+
|
|
134
|
+
Split text into sentences using spaCy's sentence boundary detection.
|
|
135
|
+
|
|
136
|
+
**Parameters:**
|
|
137
|
+
|
|
138
|
+
- `text`: Input text string
|
|
139
|
+
- `language_model`: spaCy model to use (default: "en_core_web_sm")
|
|
140
|
+
|
|
141
|
+
**Returns:** List of sentences
|
|
142
|
+
|
|
143
|
+
### `split_clauses(text, language_model="en_core_web_sm")`
|
|
144
|
+
|
|
145
|
+
Split text into comma-separated parts. Useful for creating natural pause points in
|
|
146
|
+
audiobook/TTS applications.
|
|
147
|
+
|
|
148
|
+
**Parameters:**
|
|
149
|
+
|
|
150
|
+
- `text`: Input text string
|
|
151
|
+
- `language_model`: spaCy model to use (default: "en_core_web_sm")
|
|
152
|
+
|
|
153
|
+
**Returns:** List of clauses (comma stays at end of each part)
|
|
154
|
+
|
|
155
|
+
### `split_paragraphs(text)`
|
|
156
|
+
|
|
157
|
+
Split text into paragraphs at double newlines.
|
|
158
|
+
|
|
159
|
+
**Parameters:**
|
|
160
|
+
|
|
161
|
+
- `text`: Input text string
|
|
162
|
+
|
|
163
|
+
**Returns:** List of paragraphs
|
|
164
|
+
|
|
165
|
+
### `split_long_lines(text, max_length, language_model="en_core_web_sm")`
|
|
166
|
+
|
|
167
|
+
Split lines exceeding max_length at sentence/clause boundaries.
|
|
168
|
+
|
|
169
|
+
**Parameters:**
|
|
170
|
+
|
|
171
|
+
- `text`: Input text string
|
|
172
|
+
- `max_length`: Maximum line length in characters
|
|
173
|
+
- `language_model`: spaCy model to use (default: "en_core_web_sm")
|
|
174
|
+
|
|
175
|
+
**Returns:** List of lines, each within max_length
|
|
176
|
+
|
|
177
|
+
## Use Cases
|
|
178
|
+
|
|
179
|
+
### Audiobook Creation
|
|
180
|
+
|
|
181
|
+
Split text at commas to create natural pause points for text-to-speech:
|
|
182
|
+
|
|
183
|
+
```python
|
|
184
|
+
from phrasplit import split_clauses
|
|
185
|
+
|
|
186
|
+
text = "When the sun rose, the birds began to sing, and the day started."
|
|
187
|
+
parts = split_clauses(text)
|
|
188
|
+
# ['When the sun rose,', 'the birds began to sing,', 'and the day started.']
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Subtitle Generation
|
|
192
|
+
|
|
193
|
+
Split long lines to fit subtitle constraints:
|
|
194
|
+
|
|
195
|
+
```python
|
|
196
|
+
from phrasplit import split_long_lines
|
|
197
|
+
|
|
198
|
+
text = "This is a very long sentence that would not fit on a single subtitle line."
|
|
199
|
+
lines = split_long_lines(text, max_length=42)
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Text Processing Pipelines
|
|
203
|
+
|
|
204
|
+
```python
|
|
205
|
+
from phrasplit import split_paragraphs, split_sentences
|
|
206
|
+
|
|
207
|
+
text = open("book.txt").read()
|
|
208
|
+
|
|
209
|
+
for paragraph in split_paragraphs(text):
|
|
210
|
+
for sentence in split_sentences(paragraph):
|
|
211
|
+
process(sentence)
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
## Requirements
|
|
215
|
+
|
|
216
|
+
- Python 3.9+
|
|
217
|
+
- spaCy 3.5+
|
|
218
|
+
- click 8.0+
|
|
219
|
+
- rich 13.0+
|
|
220
|
+
|
|
221
|
+
## License
|
|
222
|
+
|
|
223
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
224
|
+
|
|
225
|
+
## Contributing
|
|
226
|
+
|
|
227
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|