unicode-segment 0.4.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.
- unicode_segment-0.4.0/LICENSE.txt +21 -0
- unicode_segment-0.4.0/PKG-INFO +79 -0
- unicode_segment-0.4.0/README.md +28 -0
- unicode_segment-0.4.0/pyproject.toml +47 -0
- unicode_segment-0.4.0/setup.cfg +4 -0
- unicode_segment-0.4.0/src/unicode_segment/__init__.py +3 -0
- unicode_segment-0.4.0/src/unicode_segment/_rule_parser.py +589 -0
- unicode_segment-0.4.0/src/unicode_segment/_segmenter.py +57 -0
- unicode_segment-0.4.0/src/unicode_segment/_segmenter_config.py +18 -0
- unicode_segment-0.4.0/src/unicode_segment/grapheme.py +52 -0
- unicode_segment-0.4.0/src/unicode_segment/sentence.py +48 -0
- unicode_segment-0.4.0/src/unicode_segment/word.py +67 -0
- unicode_segment-0.4.0/src/unicode_segment.egg-info/PKG-INFO +79 -0
- unicode_segment-0.4.0/src/unicode_segment.egg-info/SOURCES.txt +19 -0
- unicode_segment-0.4.0/src/unicode_segment.egg-info/dependency_links.txt +1 -0
- unicode_segment-0.4.0/src/unicode_segment.egg-info/requires.txt +1 -0
- unicode_segment-0.4.0/src/unicode_segment.egg-info/top_level.txt +1 -0
- unicode_segment-0.4.0/tests/test_bench.py +112 -0
- unicode_segment-0.4.0/tests/test_rule_parser.py +483 -0
- unicode_segment-0.4.0/tests/test_segmenters.py +96 -0
- unicode_segment-0.4.0/tests/test_sentence.py +43 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Lionel Rowe
|
|
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.
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: unicode-segment
|
|
3
|
+
Version: 0.4.0
|
|
4
|
+
Summary: Segment text with Unicode TR29-compliant segmenters.
|
|
5
|
+
Author-email: Lionel Rowe <lionel.rowe@gmail.com>
|
|
6
|
+
Maintainer-email: Lionel Rowe <lionel.rowe@gmail.com>
|
|
7
|
+
License: MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2025 Lionel Rowe
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
Project-URL: Homepage, https://github.com/lionel-rowe/unicode-segment
|
|
30
|
+
Project-URL: Bug Reports, https://github.com/lionel-rowe/unicode-segment/issues
|
|
31
|
+
Project-URL: Source, https://github.com/lionel-rowe/unicode-segment/
|
|
32
|
+
Keywords: unicode,text-segmentation,segmenter,tr29,sentence,i18n
|
|
33
|
+
Classifier: Development Status :: 3 - Alpha
|
|
34
|
+
Classifier: Intended Audience :: Developers
|
|
35
|
+
Classifier: Operating System :: OS Independent
|
|
36
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
37
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
38
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
39
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
40
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
41
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
42
|
+
Classifier: Topic :: Text Processing
|
|
43
|
+
Classifier: Topic :: Text Processing :: General
|
|
44
|
+
Classifier: Topic :: Software Development :: Internationalization
|
|
45
|
+
Classifier: Topic :: Software Development :: Localization
|
|
46
|
+
Requires-Python: >=3.9
|
|
47
|
+
Description-Content-Type: text/markdown
|
|
48
|
+
License-File: LICENSE.txt
|
|
49
|
+
Requires-Dist: regex>=2025.11.3
|
|
50
|
+
Dynamic: license-file
|
|
51
|
+
|
|
52
|
+
# Unicode Segment
|
|
53
|
+
|
|
54
|
+
Segment text with Unicode [TR29](https://www.unicode.org/reports/tr29/)-compliant segmenters.
|
|
55
|
+
|
|
56
|
+
## Usage
|
|
57
|
+
|
|
58
|
+
```py
|
|
59
|
+
from unicode_segment import SentenceSegmenter
|
|
60
|
+
|
|
61
|
+
text = """This, that, the other thing, etc. Another sentence... A, b, c, \
|
|
62
|
+
etc., and more. D, e, f, etc. and more. One, i. e. two. Three, i. e., four. \
|
|
63
|
+
Five, i.e. six. You have 4.2 messages. Property access: `a.b.c`."""
|
|
64
|
+
|
|
65
|
+
segmenter = SentenceSegmenter()
|
|
66
|
+
segments = segmenter.segment(text)
|
|
67
|
+
|
|
68
|
+
assert list(segments) == [
|
|
69
|
+
(0, "This, that, the other thing, etc. "),
|
|
70
|
+
(34, "Another sentence... "),
|
|
71
|
+
(54, "A, b, c, etc., and more. "),
|
|
72
|
+
(79, "D, e, f, etc. and more. "),
|
|
73
|
+
(103, "One, i. e. two. "),
|
|
74
|
+
(119, "Three, i. e., four. "),
|
|
75
|
+
(139, "Five, i.e. six. "),
|
|
76
|
+
(155, "You have 4.2 messages. "),
|
|
77
|
+
(178, "Property access: `a.b.c`."),
|
|
78
|
+
]
|
|
79
|
+
```
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Unicode Segment
|
|
2
|
+
|
|
3
|
+
Segment text with Unicode [TR29](https://www.unicode.org/reports/tr29/)-compliant segmenters.
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```py
|
|
8
|
+
from unicode_segment import SentenceSegmenter
|
|
9
|
+
|
|
10
|
+
text = """This, that, the other thing, etc. Another sentence... A, b, c, \
|
|
11
|
+
etc., and more. D, e, f, etc. and more. One, i. e. two. Three, i. e., four. \
|
|
12
|
+
Five, i.e. six. You have 4.2 messages. Property access: `a.b.c`."""
|
|
13
|
+
|
|
14
|
+
segmenter = SentenceSegmenter()
|
|
15
|
+
segments = segmenter.segment(text)
|
|
16
|
+
|
|
17
|
+
assert list(segments) == [
|
|
18
|
+
(0, "This, that, the other thing, etc. "),
|
|
19
|
+
(34, "Another sentence... "),
|
|
20
|
+
(54, "A, b, c, etc., and more. "),
|
|
21
|
+
(79, "D, e, f, etc. and more. "),
|
|
22
|
+
(103, "One, i. e. two. "),
|
|
23
|
+
(119, "Three, i. e., four. "),
|
|
24
|
+
(139, "Five, i.e. six. "),
|
|
25
|
+
(155, "You have 4.2 messages. "),
|
|
26
|
+
(178, "Property access: `a.b.c`."),
|
|
27
|
+
]
|
|
28
|
+
```
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "unicode-segment"
|
|
3
|
+
version = "0.4.0"
|
|
4
|
+
description = "Segment text with Unicode TR29-compliant segmenters."
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
requires-python = ">=3.9"
|
|
7
|
+
license = { file = "LICENSE.txt" }
|
|
8
|
+
keywords = ["unicode", "text-segmentation", "segmenter", "tr29", "sentence", "i18n"]
|
|
9
|
+
authors = [{ name = "Lionel Rowe", email = "lionel.rowe@gmail.com" }]
|
|
10
|
+
maintainers = [{ name = "Lionel Rowe", email = "lionel.rowe@gmail.com" }]
|
|
11
|
+
dependencies = [
|
|
12
|
+
"regex>=2025.11.3",
|
|
13
|
+
]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
"Programming Language :: Python :: 3.9",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Programming Language :: Python :: 3.14",
|
|
24
|
+
"Topic :: Text Processing",
|
|
25
|
+
"Topic :: Text Processing :: General",
|
|
26
|
+
"Topic :: Software Development :: Internationalization",
|
|
27
|
+
"Topic :: Software Development :: Localization",
|
|
28
|
+
]
|
|
29
|
+
|
|
30
|
+
[project.urls]
|
|
31
|
+
"Homepage" = "https://github.com/lionel-rowe/unicode-segment"
|
|
32
|
+
"Bug Reports" = "https://github.com/lionel-rowe/unicode-segment/issues"
|
|
33
|
+
"Source" = "https://github.com/lionel-rowe/unicode-segment/"
|
|
34
|
+
|
|
35
|
+
[build-system]
|
|
36
|
+
requires = ["setuptools"]
|
|
37
|
+
build-backend = "setuptools.build_meta"
|
|
38
|
+
|
|
39
|
+
[dependency-groups]
|
|
40
|
+
dev = [
|
|
41
|
+
"faker>=37.12.0",
|
|
42
|
+
"mypy>=1.18.2",
|
|
43
|
+
"pytest>=8.4.2",
|
|
44
|
+
"pytest-benchmark>=5.2.3",
|
|
45
|
+
"pytest-ruff>=0.5",
|
|
46
|
+
"types-regex>=2025.11.3.20251106",
|
|
47
|
+
]
|