fast-sentence-segment 0.1.9__py3-none-any.whl → 1.1.8__py3-none-any.whl
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.
- fast_sentence_segment/__init__.py +18 -18
- fast_sentence_segment/bp/__init__.py +1 -1
- fast_sentence_segment/bp/segmenter.py +65 -68
- fast_sentence_segment/core/__init__.py +4 -0
- fast_sentence_segment/core/base_object.py +18 -0
- fast_sentence_segment/core/stopwatch.py +38 -0
- fast_sentence_segment/dmo/__init__.py +6 -6
- fast_sentence_segment/dmo/bullet_point_cleaner.py +55 -55
- fast_sentence_segment/dmo/delimiters_to_periods.py +37 -37
- fast_sentence_segment/dmo/newlines_to_periods.py +57 -57
- fast_sentence_segment/dmo/numbered_list_normalizer.py +53 -53
- fast_sentence_segment/dmo/post_process_sentences.py +48 -48
- fast_sentence_segment/dmo/spacy_doc_segmenter.py +101 -101
- fast_sentence_segment/svc/__init__.py +2 -2
- fast_sentence_segment/svc/perform_paragraph_segmentation.py +50 -50
- fast_sentence_segment/svc/perform_sentence_segmentation.py +129 -129
- fast_sentence_segment-1.1.8.dist-info/METADATA +146 -0
- fast_sentence_segment-1.1.8.dist-info/RECORD +20 -0
- {fast_sentence_segment-0.1.9.dist-info → fast_sentence_segment-1.1.8.dist-info}/WHEEL +1 -1
- fast_sentence_segment-1.1.8.dist-info/licenses/LICENSE +21 -0
- fast_sentence_segment-0.1.9.dist-info/METADATA +0 -54
- fast_sentence_segment-0.1.9.dist-info/RECORD +0 -16
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: fast-sentence-segment
|
|
3
|
+
Version: 1.1.8
|
|
4
|
+
Summary: Fast and Efficient Sentence Segmentation
|
|
5
|
+
License: MIT
|
|
6
|
+
License-File: LICENSE
|
|
7
|
+
Keywords: nlp,text,preprocess,segment
|
|
8
|
+
Author: Craig Trim
|
|
9
|
+
Author-email: craigtrim@gmail.com
|
|
10
|
+
Maintainer: Craig Trim
|
|
11
|
+
Maintainer-email: craigtrim@gmail.com
|
|
12
|
+
Requires-Python: >=3.9,<4.0
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
23
|
+
Requires-Dist: spacy (>=3.8.0,<4.0.0)
|
|
24
|
+
Project-URL: Bug Tracker, https://github.com/craigtrim/fast-sentence-segment/issues
|
|
25
|
+
Project-URL: Repository, https://github.com/craigtrim/fast-sentence-segment
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# Fast Sentence Segmentation
|
|
29
|
+
|
|
30
|
+
[](https://pypi.org/project/fast-sentence-segment/)
|
|
31
|
+
[](https://pypi.org/project/fast-sentence-segment/)
|
|
32
|
+
[](https://opensource.org/licenses/MIT)
|
|
33
|
+
[](https://spacy.io/)
|
|
34
|
+
|
|
35
|
+
Fast and efficient sentence segmentation using spaCy. Handles complex edge cases like abbreviations (Dr., Mr., etc.), quoted text, and multi-paragraph documents.
|
|
36
|
+
|
|
37
|
+
## Features
|
|
38
|
+
|
|
39
|
+
- **Paragraph-aware segmentation**: Returns sentences grouped by paragraph
|
|
40
|
+
- **Abbreviation handling**: Correctly handles "Dr.", "Mr.", "etc." without false splits
|
|
41
|
+
- **Cached processing**: LRU cache for repeated text processing
|
|
42
|
+
- **Flexible output**: Nested lists (by paragraph) or flattened list of sentences
|
|
43
|
+
- **Bullet point & numbered list normalization**: Cleans common list formats
|
|
44
|
+
|
|
45
|
+
## Installation
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install fast-sentence-segment
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
After installation, download the spaCy model:
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
python -m spacy download en_core_web_sm
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Quick Start
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
from fast_sentence_segment import segment_text
|
|
61
|
+
|
|
62
|
+
text = "Here is a Dr. who says something. And then again, what else? I don't know. Do you?"
|
|
63
|
+
|
|
64
|
+
results = segment_text(text)
|
|
65
|
+
# Returns: [['Here is a Dr. who says something.', 'And then again, what else?', "I don't know.", 'Do you?']]
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Usage
|
|
69
|
+
|
|
70
|
+
### Basic Segmentation
|
|
71
|
+
|
|
72
|
+
The `segment_text` function returns a list of lists, where each inner list represents a paragraph containing its sentences:
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
from fast_sentence_segment import segment_text
|
|
76
|
+
|
|
77
|
+
text = """First paragraph here. It has two sentences.
|
|
78
|
+
|
|
79
|
+
Second paragraph starts here. This one also has multiple sentences. And a third."""
|
|
80
|
+
|
|
81
|
+
results = segment_text(text)
|
|
82
|
+
# Returns:
|
|
83
|
+
# [
|
|
84
|
+
# ['First paragraph here.', 'It has two sentences.'],
|
|
85
|
+
# ['Second paragraph starts here.', 'This one also has multiple sentences.', 'And a third.']
|
|
86
|
+
# ]
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Flattened Output
|
|
90
|
+
|
|
91
|
+
If you don't need paragraph boundaries, use the `flatten` parameter:
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
results = segment_text(text, flatten=True)
|
|
95
|
+
# Returns: ['First paragraph here.', 'It has two sentences.', 'Second paragraph starts here.', ...]
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Direct Segmenter Access
|
|
99
|
+
|
|
100
|
+
For more control, use the `Segmenter` class directly:
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from fast_sentence_segment import Segmenter
|
|
104
|
+
|
|
105
|
+
segmenter = Segmenter()
|
|
106
|
+
results = segmenter.input_text("Your text here.")
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## API Reference
|
|
110
|
+
|
|
111
|
+
| Function | Parameters | Returns | Description |
|
|
112
|
+
|----------|------------|---------|-------------|
|
|
113
|
+
| `segment_text()` | `input_text: str`, `flatten: bool = False` | `list` | Main entry point for segmentation |
|
|
114
|
+
| `Segmenter.input_text()` | `input_text: str` | `list[list[str]]` | Cached paragraph-aware segmentation |
|
|
115
|
+
|
|
116
|
+
## Why Nested Lists?
|
|
117
|
+
|
|
118
|
+
The segmentation process preserves document structure by segmenting into both paragraphs and sentences. Each outer list represents a paragraph, and each inner list contains that paragraph's sentences. This is useful for:
|
|
119
|
+
|
|
120
|
+
- Document structure analysis
|
|
121
|
+
- Paragraph-level processing
|
|
122
|
+
- Maintaining original text organization
|
|
123
|
+
|
|
124
|
+
Use `flatten=True` when you only need sentences without paragraph context.
|
|
125
|
+
|
|
126
|
+
## Requirements
|
|
127
|
+
|
|
128
|
+
- Python 3.8.5+
|
|
129
|
+
- spaCy 3.5.3
|
|
130
|
+
- en_core_web_sm spaCy model
|
|
131
|
+
|
|
132
|
+
## License
|
|
133
|
+
|
|
134
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
135
|
+
|
|
136
|
+
## Contributing
|
|
137
|
+
|
|
138
|
+
Contributions are welcome! Please feel free to submit a Pull Request.
|
|
139
|
+
|
|
140
|
+
1. Fork the repository
|
|
141
|
+
2. Create your feature branch (`git checkout -b feature/amazing-feature`)
|
|
142
|
+
3. Run tests (`make test`)
|
|
143
|
+
4. Commit your changes
|
|
144
|
+
5. Push to the branch
|
|
145
|
+
6. Open a Pull Request
|
|
146
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
fast_sentence_segment/__init__.py,sha256=HTONyC0JLVWTAHyvJO6rMINmxymbfMpARtGeRw5iIsQ,359
|
|
2
|
+
fast_sentence_segment/bp/__init__.py,sha256=j2-WfQ9WwVuXeGSjvV6XLVwEdvau8sdAQe4Pa4DrYi8,33
|
|
3
|
+
fast_sentence_segment/bp/segmenter.py,sha256=UW6DguPgA56h-pPYRsfJhjIzBe40j6NdjkwYxamASyA,1928
|
|
4
|
+
fast_sentence_segment/core/__init__.py,sha256=uoBersYyVStJ5a8zJpQz1GDGaloEdAv2jGHw1292hRM,108
|
|
5
|
+
fast_sentence_segment/core/base_object.py,sha256=AYr7yzusIwawjbKdvcv4yTEnhmx6M583kDZzhzPOmq4,635
|
|
6
|
+
fast_sentence_segment/core/stopwatch.py,sha256=hE6hMz2q6rduaKi58KZmiAL-lRtyh_wWCANhl4KLkRQ,879
|
|
7
|
+
fast_sentence_segment/dmo/__init__.py,sha256=Tz1ICwhQLimQ3KoZM4f5HQFFgYamnMAn4opcyIB7Chk,328
|
|
8
|
+
fast_sentence_segment/dmo/bullet_point_cleaner.py,sha256=WOZQRWXiiyRi8rOuEIw36EmkaXmATHL9_Dxb2rderw4,1606
|
|
9
|
+
fast_sentence_segment/dmo/delimiters_to_periods.py,sha256=cshN3TU2YzCHWVGGDnd_FOQJluyRExpYPrpZ_BQQeko,857
|
|
10
|
+
fast_sentence_segment/dmo/newlines_to_periods.py,sha256=PUrXreqZWiITINfoJL5xRRlXJH6noH0cdXtW1EqAh8I,1517
|
|
11
|
+
fast_sentence_segment/dmo/numbered_list_normalizer.py,sha256=q0cLiTUt6ITX_cCwCRrIR7A3o92WOKVWpFWs8P5Gu5M,1549
|
|
12
|
+
fast_sentence_segment/dmo/post_process_sentences.py,sha256=5jxG3TmFjxIExMPLhnCB5JT1lXQvFU9r4qQGoATGrWk,916
|
|
13
|
+
fast_sentence_segment/dmo/spacy_doc_segmenter.py,sha256=0icAkSQwAUQo3VYqQ2PUjW6-MOU5RNCGPX3-fB5YfCc,2554
|
|
14
|
+
fast_sentence_segment/svc/__init__.py,sha256=9B12mXxBnlalH4OAm1AMLwUMa-RLi2ilv7qhqv26q7g,144
|
|
15
|
+
fast_sentence_segment/svc/perform_paragraph_segmentation.py,sha256=zLKw9rSzb0NNfx4MyEeoGrHwhxTtH5oDrYcAL2LMVHY,1378
|
|
16
|
+
fast_sentence_segment/svc/perform_sentence_segmentation.py,sha256=ZT231A5CJ5v9tGpYbny_eq8SzgEdEwVTCVu9OV_UO9g,3839
|
|
17
|
+
fast_sentence_segment-1.1.8.dist-info/METADATA,sha256=mCHUoRPcbOcSlffv6-da66W2KZU6P5OUBQFnGFgJhQU,4817
|
|
18
|
+
fast_sentence_segment-1.1.8.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
|
|
19
|
+
fast_sentence_segment-1.1.8.dist-info/licenses/LICENSE,sha256=vou5JCLAT5nHcsUv-AkjUYAihYfN9mwPDXxV2DHyHBo,1067
|
|
20
|
+
fast_sentence_segment-1.1.8.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Craig Trim
|
|
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.
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: fast-sentence-segment
|
|
3
|
-
Version: 0.1.9
|
|
4
|
-
Summary: Fast and Efficient Sentence Segmentation
|
|
5
|
-
Home-page: https://github.com/craigtrim/fast-sentence-segment
|
|
6
|
-
License: None
|
|
7
|
-
Keywords: nlp,text,preprocess,segment
|
|
8
|
-
Author: Craig Trim
|
|
9
|
-
Author-email: craigtrim@gmail.com
|
|
10
|
-
Maintainer: Craig Trim
|
|
11
|
-
Maintainer-email: craigtrim@gmail.com
|
|
12
|
-
Requires-Python: >=3.8.5,<4.0.0
|
|
13
|
-
Classifier: Development Status :: 4 - Beta
|
|
14
|
-
Classifier: License :: Other/Proprietary License
|
|
15
|
-
Classifier: Programming Language :: Python :: 3
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
19
|
-
Requires-Dist: baseblock
|
|
20
|
-
Requires-Dist: spacy (==3.5.0)
|
|
21
|
-
Project-URL: Bug Tracker, https://github.com/craigtrim/fast-sentence-segment/issues
|
|
22
|
-
Project-URL: Repository, https://github.com/craigtrim/fast-sentence-segment
|
|
23
|
-
Description-Content-Type: text/markdown
|
|
24
|
-
|
|
25
|
-
# Fast Sentence Segmentation (fast-sentence-segment)
|
|
26
|
-
Fast and Efficient Sentence Segmentation
|
|
27
|
-
|
|
28
|
-
Usage
|
|
29
|
-
```python
|
|
30
|
-
from fast_sentence_segment import segment_text
|
|
31
|
-
|
|
32
|
-
results = segment_text(
|
|
33
|
-
'here is a dr. who says something. and then again, what else? i dont know. Do you?')
|
|
34
|
-
|
|
35
|
-
assert results == [
|
|
36
|
-
[
|
|
37
|
-
'here is a dr. who says something.',
|
|
38
|
-
'and then again, what else?',
|
|
39
|
-
'i dont know.',
|
|
40
|
-
'Do you?'
|
|
41
|
-
]
|
|
42
|
-
]
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
Why use a double-scripted list?
|
|
46
|
-
|
|
47
|
-
The segementation process will segment into paragraphs and sentences. A paragraph is composed of 1..* sentences, hence each list of lists is equivalent to a paragraph.
|
|
48
|
-
|
|
49
|
-
This usage
|
|
50
|
-
```python
|
|
51
|
-
results = segment_text(input_text, flatten=True)
|
|
52
|
-
```
|
|
53
|
-
Will return a list of strings, regardless of paragraph delimitation.
|
|
54
|
-
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
fast_sentence_segment/__init__.py,sha256=otzCTZrivtWR5GbQ_-eCfYgwKhyNCL2XGM17YNI1YWo,377
|
|
2
|
-
fast_sentence_segment/bp/__init__.py,sha256=M0y9HPbk6hrB1yiG7Fd8G8UGoO05IRZzOgInMBe883g,34
|
|
3
|
-
fast_sentence_segment/bp/segmenter.py,sha256=h0xnNUkeoz_AyDXCocUozCx8X40FmWgm8xJsN3DoCYg,1966
|
|
4
|
-
fast_sentence_segment/dmo/__init__.py,sha256=sVkdjzjCV_8BAMZBiuuAYs_1MUSpdo7YxC2ThRnBhPI,334
|
|
5
|
-
fast_sentence_segment/dmo/bullet_point_cleaner.py,sha256=K6hsLttTq3xxLJnQijxYQUAGISoDuUKiGQM7oiQgEBU,1644
|
|
6
|
-
fast_sentence_segment/dmo/delimiters_to_periods.py,sha256=CJrxKnADZhMnXlOXLSuLupq9aGvp_ir4LyKTQE4SByU,877
|
|
7
|
-
fast_sentence_segment/dmo/newlines_to_periods.py,sha256=EnafiZ1TQvqZXXHNEmvCveuUtolIUc8oaCOFHAb0nnw,1557
|
|
8
|
-
fast_sentence_segment/dmo/numbered_list_normalizer.py,sha256=ljbEyabjjA1IWYD17ryu4_UKaa0WEfpE9LCa-laaplo,1585
|
|
9
|
-
fast_sentence_segment/dmo/post_process_sentences.py,sha256=vyKF89guI_EO_qkY0Uh4JeVbJr_SwEQYfBKAwhiSTKU,947
|
|
10
|
-
fast_sentence_segment/dmo/spacy_doc_segmenter.py,sha256=HAVYyTjzmuC0zcG36rJ48Ueq7tXfTplB-y5vb3p64CE,2638
|
|
11
|
-
fast_sentence_segment/svc/__init__.py,sha256=4nQTjRMoSu1n_2p8o1I7xyhOe8_kGZJ3TghgzVLGAos,146
|
|
12
|
-
fast_sentence_segment/svc/perform_paragraph_segmentation.py,sha256=mYlXvwz0JTbIUSfZeD49fG7nFe5V6eIKOIL9HqQDyII,1403
|
|
13
|
-
fast_sentence_segment/svc/perform_sentence_segmentation.py,sha256=Q6KBt83iQ662L6EgyTsfWBk-aOqcltRt0Y9MhYhqJsI,3943
|
|
14
|
-
fast_sentence_segment-0.1.9.dist-info/WHEEL,sha256=y3eDiaFVSNTPbgzfNn0nYn5tEn1cX6WrdetDlQM4xWw,83
|
|
15
|
-
fast_sentence_segment-0.1.9.dist-info/METADATA,sha256=Uc1zNsXLHGdtfcklI4g0gj0pkLv_0PSOQoXObLuuxjk,1733
|
|
16
|
-
fast_sentence_segment-0.1.9.dist-info/RECORD,,
|