fast-sentence-segment 0.1.9__py3-none-any.whl → 1.2.0__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.
Files changed (30) hide show
  1. fast_sentence_segment/__init__.py +18 -18
  2. fast_sentence_segment/bp/__init__.py +1 -1
  3. fast_sentence_segment/bp/segmenter.py +65 -68
  4. fast_sentence_segment/cli.py +56 -0
  5. fast_sentence_segment/core/__init__.py +4 -0
  6. fast_sentence_segment/core/base_object.py +18 -0
  7. fast_sentence_segment/core/stopwatch.py +38 -0
  8. fast_sentence_segment/dmo/__init__.py +10 -6
  9. fast_sentence_segment/dmo/abbreviation_merger.py +146 -0
  10. fast_sentence_segment/dmo/abbreviation_splitter.py +95 -0
  11. fast_sentence_segment/dmo/abbreviations.py +96 -0
  12. fast_sentence_segment/dmo/bullet_point_cleaner.py +55 -55
  13. fast_sentence_segment/dmo/ellipsis_normalizer.py +45 -0
  14. fast_sentence_segment/dmo/newlines_to_periods.py +57 -57
  15. fast_sentence_segment/dmo/numbered_list_normalizer.py +47 -53
  16. fast_sentence_segment/dmo/post_process_sentences.py +48 -48
  17. fast_sentence_segment/dmo/question_exclamation_splitter.py +59 -0
  18. fast_sentence_segment/dmo/spacy_doc_segmenter.py +101 -101
  19. fast_sentence_segment/dmo/title_name_merger.py +152 -0
  20. fast_sentence_segment/svc/__init__.py +2 -2
  21. fast_sentence_segment/svc/perform_paragraph_segmentation.py +50 -50
  22. fast_sentence_segment/svc/perform_sentence_segmentation.py +165 -129
  23. fast_sentence_segment-1.2.0.dist-info/METADATA +189 -0
  24. fast_sentence_segment-1.2.0.dist-info/RECORD +27 -0
  25. {fast_sentence_segment-0.1.9.dist-info → fast_sentence_segment-1.2.0.dist-info}/WHEEL +1 -1
  26. fast_sentence_segment-1.2.0.dist-info/entry_points.txt +3 -0
  27. fast_sentence_segment-1.2.0.dist-info/licenses/LICENSE +21 -0
  28. fast_sentence_segment/dmo/delimiters_to_periods.py +0 -37
  29. fast_sentence_segment-0.1.9.dist-info/METADATA +0 -54
  30. fast_sentence_segment-0.1.9.dist-info/RECORD +0 -16
@@ -1,129 +1,165 @@
1
- #!/usr/bin/env python
2
- # -*- coding: UTF-8 -*-
3
- """ Sentence Segmentation """
4
-
5
-
6
- import spacy
7
-
8
- from baseblock import BaseObject
9
-
10
- from fast_sentence_segment.dmo import NewlinesToPeriods
11
- from fast_sentence_segment.dmo import DelimitersToPeriods
12
- from fast_sentence_segment.dmo import BulletPointCleaner
13
- from fast_sentence_segment.dmo import NumberedListNormalizer
14
- from fast_sentence_segment.dmo import SpacyDocSegmenter
15
- from fast_sentence_segment.dmo import PostProcessStructure
16
-
17
-
18
- class PerformSentenceSegmentation(BaseObject):
19
- """ Sentence Segmentation """
20
-
21
- __nlp = None
22
-
23
- def __init__(self):
24
- """ Change Log
25
-
26
- Created:
27
- 30-Sept-2021
28
- craigtrim@gmail.com
29
- Updated:
30
- 19-Oct-2022
31
- craigtrim@gmail.com
32
- * add numbered-list normalization
33
- https://github.com/craigtrim/fast-sentence-segment/issues/1
34
- """
35
- BaseObject.__init__(self, __name__)
36
- if not self.__nlp:
37
- self.__nlp = spacy.load("en_core_web_sm")
38
-
39
- self._delimiters_to_periods = DelimitersToPeriods.process
40
- self._newlines_to_periods = NewlinesToPeriods.process
41
- self._normalize_numbered_lists = NumberedListNormalizer().process
42
- self._clean_bullet_points = BulletPointCleaner.process
43
- self._spacy_segmenter = SpacyDocSegmenter(self.__nlp).process
44
- self._post_process = PostProcessStructure().process
45
-
46
- @staticmethod
47
- def _clean_punctuation(input_text: str) -> str:
48
- """ Purpose:
49
- Clean punctuation oddities; this is likely highly overfitted (for now)
50
- """
51
- if ", Inc" in input_text:
52
- input_text = input_text.replace(", Inc", " Inc")
53
-
54
- return input_text
55
-
56
- @staticmethod
57
- def _clean_spacing(a_sentence: str) -> str:
58
-
59
- # eliminate triple-space
60
- a_sentence = a_sentence.replace(' ', ' ')
61
-
62
- # treat double-space as delimiter
63
- a_sentence = a_sentence.replace(' ', '. ')
64
-
65
- return a_sentence
66
-
67
- def _process(self,
68
- input_text: str) -> list:
69
-
70
- input_text = self._delimiters_to_periods(
71
- delimiter=',',
72
- input_text=input_text)
73
-
74
- input_text = self._delimiters_to_periods(
75
- delimiter=';',
76
- input_text=input_text)
77
-
78
- input_text = self._normalize_numbered_lists(input_text)
79
-
80
- input_text = self._newlines_to_periods(input_text)
81
-
82
- input_text = self._clean_spacing(input_text)
83
- if "." not in input_text:
84
- return [input_text]
85
-
86
- input_text = self._clean_bullet_points(input_text)
87
- if "." not in input_text:
88
- return [input_text]
89
-
90
- input_text = self._clean_punctuation(input_text)
91
- if "." not in input_text:
92
- return [input_text]
93
-
94
- sentences = self._spacy_segmenter(input_text)
95
- if "." not in input_text:
96
- return [input_text]
97
-
98
- sentences = self._post_process(sentences)
99
-
100
- sentences = [
101
- self._normalize_numbered_lists(x, denormalize=True)
102
- for x in sentences
103
- ]
104
-
105
- return sentences
106
-
107
- def process(self,
108
- input_text: str) -> list:
109
- """Perform Sentence Segmentation
110
-
111
- Args:
112
- input_text (str): An input string of any length or type
113
-
114
- Raises:
115
- ValueError: input must be a string
116
-
117
- Returns:
118
- list: a list of sentences
119
- each list item is an input string of any length, but is a semantic sentence
120
- """
121
-
122
- if input_text is None or not len(input_text):
123
- raise ValueError("Empty Input")
124
-
125
- if type(input_text) != str:
126
- self.logger.warning(f"Invalid Input Text: {input_text}")
127
- return []
128
-
129
- return self._process(input_text)
1
+ #!/usr/bin/env python
2
+ # -*- coding: UTF-8 -*-
3
+ """ Sentence Segmentation """
4
+
5
+
6
+ import spacy
7
+
8
+ from fast_sentence_segment.core import BaseObject
9
+
10
+ from fast_sentence_segment.dmo import AbbreviationMerger
11
+ from fast_sentence_segment.dmo import AbbreviationSplitter
12
+ from fast_sentence_segment.dmo import TitleNameMerger
13
+ from fast_sentence_segment.dmo import EllipsisNormalizer
14
+ from fast_sentence_segment.dmo import NewlinesToPeriods
15
+ from fast_sentence_segment.dmo import BulletPointCleaner
16
+ from fast_sentence_segment.dmo import NumberedListNormalizer
17
+ from fast_sentence_segment.dmo import QuestionExclamationSplitter
18
+ from fast_sentence_segment.dmo import SpacyDocSegmenter
19
+ from fast_sentence_segment.dmo import PostProcessStructure
20
+
21
+
22
+ class PerformSentenceSegmentation(BaseObject):
23
+ """ Sentence Segmentation """
24
+
25
+ __nlp = None
26
+
27
+ def __init__(self):
28
+ """ Change Log
29
+
30
+ Created:
31
+ 30-Sept-2021
32
+ craigtrim@gmail.com
33
+ Updated:
34
+ 19-Oct-2022
35
+ craigtrim@gmail.com
36
+ * add numbered-list normalization
37
+ https://github.com/craigtrim/fast-sentence-segment/issues/1
38
+ Updated:
39
+ 27-Dec-2024
40
+ craigtrim@gmail.com
41
+ * add abbreviation-aware sentence splitting
42
+ https://github.com/craigtrim/fast-sentence-segment/issues/3
43
+ """
44
+ BaseObject.__init__(self, __name__)
45
+ if not self.__nlp:
46
+ self.__nlp = spacy.load("en_core_web_sm")
47
+
48
+ self._newlines_to_periods = NewlinesToPeriods.process
49
+ self._normalize_numbered_lists = NumberedListNormalizer().process
50
+ self._normalize_ellipses = EllipsisNormalizer().process
51
+ self._clean_bullet_points = BulletPointCleaner.process
52
+ self._spacy_segmenter = SpacyDocSegmenter(self.__nlp).process
53
+ self._abbreviation_merger = AbbreviationMerger().process
54
+ self._abbreviation_splitter = AbbreviationSplitter().process
55
+ self._question_exclamation_splitter = QuestionExclamationSplitter().process
56
+ self._title_name_merger = TitleNameMerger().process
57
+ self._post_process = PostProcessStructure().process
58
+
59
+ def _denormalize(self, text: str) -> str:
60
+ """ Restore normalized placeholders to original form """
61
+ text = self._normalize_numbered_lists(text, denormalize=True)
62
+ text = self._normalize_ellipses(text, denormalize=True)
63
+ return text
64
+
65
+ @staticmethod
66
+ def _has_sentence_punct(text: str) -> bool:
67
+ """ Check if text has sentence-ending punctuation """
68
+ return "." in text or "?" in text or "!" in text
69
+
70
+ @staticmethod
71
+ def _clean_punctuation(input_text: str) -> str:
72
+ """ Purpose:
73
+ Clean punctuation oddities; this is likely highly overfitted (for now)
74
+ """
75
+ if ", Inc" in input_text:
76
+ input_text = input_text.replace(", Inc", " Inc")
77
+
78
+ return input_text
79
+
80
+ @staticmethod
81
+ def _clean_spacing(a_sentence: str) -> str:
82
+
83
+ # eliminate triple-space
84
+ a_sentence = a_sentence.replace(' ', ' ')
85
+
86
+ # treat double-space as delimiter
87
+ a_sentence = a_sentence.replace(' ', '. ')
88
+
89
+ return a_sentence
90
+
91
+ def _process(self,
92
+ input_text: str) -> list:
93
+
94
+ # Normalize tabs to spaces
95
+ input_text = input_text.replace('\t', ' ')
96
+
97
+ input_text = self._normalize_numbered_lists(input_text)
98
+ input_text = self._normalize_ellipses(input_text)
99
+
100
+ input_text = self._newlines_to_periods(input_text)
101
+
102
+ input_text = self._clean_spacing(input_text)
103
+ if not self._has_sentence_punct(input_text):
104
+ return [self._denormalize(input_text)]
105
+
106
+ input_text = self._clean_bullet_points(input_text)
107
+ if not self._has_sentence_punct(input_text):
108
+ return [self._denormalize(input_text)]
109
+
110
+ input_text = self._clean_punctuation(input_text)
111
+ if not self._has_sentence_punct(input_text):
112
+ return [self._denormalize(input_text)]
113
+
114
+ sentences = self._spacy_segmenter(input_text)
115
+ if not self._has_sentence_punct(input_text):
116
+ return [self._denormalize(input_text)]
117
+
118
+ # Merge sentences incorrectly split at abbreviations (issue #3)
119
+ sentences = self._abbreviation_merger(sentences)
120
+
121
+ # Merge title + single-word name splits (e.g., "Dr." + "Who?" -> "Dr. Who?")
122
+ sentences = self._title_name_merger(sentences)
123
+
124
+ # Split sentences at abbreviation boundaries (issue #3)
125
+ sentences = self._abbreviation_splitter(sentences)
126
+
127
+ # Split sentences at ? and ! boundaries (issue #3)
128
+ sentences = self._question_exclamation_splitter(sentences)
129
+
130
+ sentences = self._post_process(sentences)
131
+
132
+ sentences = [
133
+ self._normalize_numbered_lists(x, denormalize=True)
134
+ for x in sentences
135
+ ]
136
+ sentences = [
137
+ self._normalize_ellipses(x, denormalize=True)
138
+ for x in sentences
139
+ ]
140
+
141
+ return sentences
142
+
143
+ def process(self,
144
+ input_text: str) -> list:
145
+ """Perform Sentence Segmentation
146
+
147
+ Args:
148
+ input_text (str): An input string of any length or type
149
+
150
+ Raises:
151
+ ValueError: input must be a string
152
+
153
+ Returns:
154
+ list: a list of sentences
155
+ each list item is an input string of any length, but is a semantic sentence
156
+ """
157
+
158
+ if input_text is None or not len(input_text):
159
+ raise ValueError("Empty Input")
160
+
161
+ if not isinstance(input_text, str):
162
+ self.logger.warning(f"Invalid Input Text: {input_text}")
163
+ return []
164
+
165
+ return self._process(input_text)
@@ -0,0 +1,189 @@
1
+ Metadata-Version: 2.4
2
+ Name: fast-sentence-segment
3
+ Version: 1.2.0
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
+ [![PyPI version](https://img.shields.io/pypi/v/fast-sentence-segment.svg)](https://pypi.org/project/fast-sentence-segment/)
31
+ [![Python versions](https://img.shields.io/pypi/pyversions/fast-sentence-segment.svg)](https://pypi.org/project/fast-sentence-segment/)
32
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
33
+ [![spaCy](https://img.shields.io/badge/spaCy-3.8-blue.svg)](https://spacy.io/)
34
+
35
+ Fast and efficient sentence segmentation using spaCy with surgical post-processing fixes. Handles complex edge cases like abbreviations (Dr., Mr., etc.), ellipses, quoted text, and multi-paragraph documents.
36
+
37
+ ## Why This Library?
38
+
39
+ 1. **Keep it local**: LLM API calls cost money and send your data to third parties. Run sentence segmentation entirely on your machine.
40
+ 2. **spaCy perfected**: spaCy is a great local model, but it makes mistakes. This library fixes most of spaCy's shortcomings.
41
+
42
+ ## Features
43
+
44
+ - **Paragraph-aware segmentation**: Returns sentences grouped by paragraph
45
+ - **Abbreviation handling**: Correctly handles "Dr.", "Mr.", "etc.", "p.m.", "a.m." without false splits
46
+ - **Ellipsis preservation**: Keeps `...` intact while detecting sentence boundaries
47
+ - **Question/exclamation splitting**: Properly splits on `?` and `!` followed by capital letters
48
+ - **Cached processing**: LRU cache for repeated text processing
49
+ - **Flexible output**: Nested lists (by paragraph) or flattened list of sentences
50
+ - **Bullet point & numbered list normalization**: Cleans common list formats
51
+ - **CLI tool**: Command-line interface for quick segmentation
52
+
53
+ ## Installation
54
+
55
+ ```bash
56
+ pip install fast-sentence-segment
57
+ ```
58
+
59
+ After installation, download the spaCy model:
60
+
61
+ ```bash
62
+ python -m spacy download en_core_web_sm
63
+ ```
64
+
65
+ ## Quick Start
66
+
67
+ ```python
68
+ from fast_sentence_segment import segment_text
69
+
70
+ text = "Here is a Dr. who says something. And then again, what else? I don't know. Do you?"
71
+
72
+ results = segment_text(text)
73
+ # Returns: [['Here is a Dr. who says something.', 'And then again, what else?', "I don't know.", 'Do you?']]
74
+ ```
75
+
76
+ ## Usage
77
+
78
+ ### Basic Segmentation
79
+
80
+ The `segment_text` function returns a list of lists, where each inner list represents a paragraph containing its sentences:
81
+
82
+ ```python
83
+ from fast_sentence_segment import segment_text
84
+
85
+ text = """First paragraph here. It has two sentences.
86
+
87
+ Second paragraph starts here. This one also has multiple sentences. And a third."""
88
+
89
+ results = segment_text(text)
90
+ # Returns:
91
+ # [
92
+ # ['First paragraph here.', 'It has two sentences.'],
93
+ # ['Second paragraph starts here.', 'This one also has multiple sentences.', 'And a third.']
94
+ # ]
95
+ ```
96
+
97
+ ### Flattened Output
98
+
99
+ If you don't need paragraph boundaries, use the `flatten` parameter:
100
+
101
+ ```python
102
+ results = segment_text(text, flatten=True)
103
+ # Returns: ['First paragraph here.', 'It has two sentences.', 'Second paragraph starts here.', ...]
104
+ ```
105
+
106
+ ### Direct Segmenter Access
107
+
108
+ For more control, use the `Segmenter` class directly:
109
+
110
+ ```python
111
+ from fast_sentence_segment import Segmenter
112
+
113
+ segmenter = Segmenter()
114
+ results = segmenter.input_text("Your text here.")
115
+ ```
116
+
117
+ ### Command Line Interface
118
+
119
+ Segment text directly from the terminal:
120
+
121
+ ```bash
122
+ # Direct text input
123
+ segment "Hello world. How are you? I am fine."
124
+
125
+ # Numbered output
126
+ segment -n "First sentence. Second sentence."
127
+
128
+ # From stdin
129
+ echo "Some text here. Another sentence." | segment
130
+
131
+ # From file
132
+ segment -f document.txt
133
+ ```
134
+
135
+ ## API Reference
136
+
137
+ | Function | Parameters | Returns | Description |
138
+ |----------|------------|---------|-------------|
139
+ | `segment_text()` | `input_text: str`, `flatten: bool = False` | `list` | Main entry point for segmentation |
140
+ | `Segmenter.input_text()` | `input_text: str` | `list[list[str]]` | Cached paragraph-aware segmentation |
141
+
142
+ ### CLI Options
143
+
144
+ | Option | Description |
145
+ |--------|-------------|
146
+ | `text` | Text to segment (positional argument) |
147
+ | `-f, --file` | Read text from file |
148
+ | `-n, --numbered` | Number output lines |
149
+
150
+ ## Why Nested Lists?
151
+
152
+ 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:
153
+
154
+ - Document structure analysis
155
+ - Paragraph-level processing
156
+ - Maintaining original text organization
157
+
158
+ Use `flatten=True` when you only need sentences without paragraph context.
159
+
160
+ ## Requirements
161
+
162
+ - Python 3.9+
163
+ - spaCy 3.8+
164
+ - en_core_web_sm spaCy model
165
+
166
+ ## How It Works
167
+
168
+ This library uses spaCy for initial sentence segmentation, then applies surgical post-processing fixes for cases where spaCy's default behavior is incorrect:
169
+
170
+ 1. **Pre-processing**: Normalize numbered lists, preserve ellipses with placeholders
171
+ 2. **spaCy segmentation**: Use spaCy's sentence boundary detection
172
+ 3. **Post-processing**: Split on abbreviation boundaries, handle `?`/`!` + capital patterns
173
+ 4. **Denormalization**: Restore placeholders to original text
174
+
175
+ ## License
176
+
177
+ MIT License - see [LICENSE](LICENSE) for details.
178
+
179
+ ## Contributing
180
+
181
+ Contributions are welcome! Please feel free to submit a Pull Request.
182
+
183
+ 1. Fork the repository
184
+ 2. Create your feature branch (`git checkout -b feature/amazing-feature`)
185
+ 3. Run tests (`make test`)
186
+ 4. Commit your changes
187
+ 5. Push to the branch
188
+ 6. Open a Pull Request
189
+
@@ -0,0 +1,27 @@
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/cli.py,sha256=X2dMLkfc2dtheig62wKC75AohfW0Y9oTU0ORhGUFkbQ,1250
5
+ fast_sentence_segment/core/__init__.py,sha256=uoBersYyVStJ5a8zJpQz1GDGaloEdAv2jGHw1292hRM,108
6
+ fast_sentence_segment/core/base_object.py,sha256=AYr7yzusIwawjbKdvcv4yTEnhmx6M583kDZzhzPOmq4,635
7
+ fast_sentence_segment/core/stopwatch.py,sha256=hE6hMz2q6rduaKi58KZmiAL-lRtyh_wWCANhl4KLkRQ,879
8
+ fast_sentence_segment/dmo/__init__.py,sha256=E70tkpdHu86KP2dwBX5Dy5D7eNiU6fzucrfDJOY1ui4,551
9
+ fast_sentence_segment/dmo/abbreviation_merger.py,sha256=tCXM6yCfMryJvMIVWIxP_EocoibZi8vohFzJ5tvMYr0,4432
10
+ fast_sentence_segment/dmo/abbreviation_splitter.py,sha256=03mSyJcLooNyIjXx6mPlrnjmKgZW-uhUIqG4U-MbIGw,2981
11
+ fast_sentence_segment/dmo/abbreviations.py,sha256=7mpEoOnw5MH8URYmmpxaYs3Wc2eqy4pC0hAnYfYSdck,1639
12
+ fast_sentence_segment/dmo/bullet_point_cleaner.py,sha256=WOZQRWXiiyRi8rOuEIw36EmkaXmATHL9_Dxb2rderw4,1606
13
+ fast_sentence_segment/dmo/ellipsis_normalizer.py,sha256=lHs9dLFfKJe-2vFNe17Hik90g3_kXX347OzGP_IOT08,1521
14
+ fast_sentence_segment/dmo/newlines_to_periods.py,sha256=PUrXreqZWiITINfoJL5xRRlXJH6noH0cdXtW1EqAh8I,1517
15
+ fast_sentence_segment/dmo/numbered_list_normalizer.py,sha256=q0sOCW8Jkn2vTXlUcVhmDvYES3yvJx1oUVl_8y7eL4E,1672
16
+ fast_sentence_segment/dmo/post_process_sentences.py,sha256=5jxG3TmFjxIExMPLhnCB5JT1lXQvFU9r4qQGoATGrWk,916
17
+ fast_sentence_segment/dmo/question_exclamation_splitter.py,sha256=cRsWRu8zb6wOWG-BjMahHfz4YGutKiV9lW7dE-q3tgc,2006
18
+ fast_sentence_segment/dmo/spacy_doc_segmenter.py,sha256=0icAkSQwAUQo3VYqQ2PUjW6-MOU5RNCGPX3-fB5YfCc,2554
19
+ fast_sentence_segment/dmo/title_name_merger.py,sha256=zbG04_VjwM8TtT8LhavvmZqIZL_2xgT2OTxWkK_Zt1s,5133
20
+ fast_sentence_segment/svc/__init__.py,sha256=9B12mXxBnlalH4OAm1AMLwUMa-RLi2ilv7qhqv26q7g,144
21
+ fast_sentence_segment/svc/perform_paragraph_segmentation.py,sha256=zLKw9rSzb0NNfx4MyEeoGrHwhxTtH5oDrYcAL2LMVHY,1378
22
+ fast_sentence_segment/svc/perform_sentence_segmentation.py,sha256=dqGxFsJoP6ox_MJwtB85R9avEbBAR4x9YKaRaQ5fAXo,5723
23
+ fast_sentence_segment-1.2.0.dist-info/METADATA,sha256=05V3aFKHCD9JaYN8va_vIuMtaoAbGmKgFAOUDJWfM80,6405
24
+ fast_sentence_segment-1.2.0.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
25
+ fast_sentence_segment-1.2.0.dist-info/entry_points.txt,sha256=mDiRuKOZlOeqmtH1eZwqGEGM6KUh0RTzwyETGMpxSDI,58
26
+ fast_sentence_segment-1.2.0.dist-info/licenses/LICENSE,sha256=vou5JCLAT5nHcsUv-AkjUYAihYfN9mwPDXxV2DHyHBo,1067
27
+ fast_sentence_segment-1.2.0.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry 1.0.7
2
+ Generator: poetry-core 2.2.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ segment=fast_sentence_segment.cli:main
3
+
@@ -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,37 +0,0 @@
1
- #!/usr/bin/env python
2
- # -*- coding: UTF-8 -*-
3
- """ Convert Delimiters into Periods """
4
-
5
-
6
- from baseblock import BaseObject
7
-
8
-
9
- class DelimitersToPeriods(BaseObject):
10
- """ Convert Delimiters into Periods """
11
-
12
- def __init__(self):
13
- """
14
- Created:
15
- 30-Sept-2021
16
- """
17
- BaseObject.__init__(self, __name__)
18
-
19
- @staticmethod
20
- def process(input_text: str,
21
- delimiter: str):
22
- """
23
- Purpose:
24
- Take a CSV list and transform to sentences
25
- :param input_text:
26
- :return:
27
- """
28
- total_len = len(input_text)
29
- total_delims = input_text.count(delimiter)
30
-
31
- if total_delims == 0:
32
- return input_text
33
-
34
- if total_delims / total_len > 0.04:
35
- return input_text.replace(delimiter, '.')
36
-
37
- return input_text
@@ -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,,