Registry / data / sentence-stream

sentence-stream

JSON →
library1.3.0pypypi✓ verified 83d ago

Sentence Stream is a small, pure Python library for splitting text into sentences. It is designed to work efficiently with text streams, such as large files or network streams, by processing text incrementally without loading the entire content into memory. The current version is 1.3.0, and it maintains an active release cadence for improvements and bug fixes.

pip install sentence-stream
INSTALL
IMPORT
SIG · SENTENCE-STREAM
S
sentence-stream
datapythonv1.3.0
Install
2.4s avg
Import
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.3.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.910 runs
installs and imports cleanly · install 0.0s · import 0.000s · 20.5MB
glibc
py 3.103.910 runs
installs and imports cleanly · install 2.4s · import 0.000s · 22MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

SentenceBoundaryDetector
from sentence_stream import SentenceBoundaryDetector
from sentence_stream import SentenceStream
stream_to_sentences
from sentence_stream import stream_to_sentences
async_stream_to_sentences
from sentence_stream import async_stream_to_sentences

Initialize `SentenceStream` with a string or an iterable (like a file-like object). The instance is itself an iterable, yielding sentences one by one.

from sentence_stream import SentenceStream # Example with a simple string text_input = "Hello world. This is a test. Another sentence.\nNew paragraph. One more?" stream = SentenceStream(text_input) print("--- Processing string input ---") for sentence in stream: print(f"'{sentence}'") # Example with a file-like object (simulate stream) import io long_text = "This is the first sentence. And here is the second one. " \ "The third sentence continues here. Finally, a fourth." \ "This could be a very large file." * 10 file_stream = io.StringIO(long_text) stream_from_file = SentenceStream(file_stream) print("\n--- Processing file-like object ---") sentences_count = 0 for sentence in stream_from_file: # print(f"'{sentence}'") # Uncomment to see all sentences sentences_count += 1 print(f"Processed {sentences_count} sentences from stream.")
Debug
Known issues
gotchaThis library provides a rule-based sentence splitter and is not intended for advanced Natural Language Processing (NLP) tokenization that requires deep linguistic understanding or model-based analysis. It focuses on basic punctuation-driven splitting.
fix
For complex NLP tasks, consider libraries like spaCy, NLTK, or Hugging Face Transformers, which offer more sophisticated sentence boundary detection algorithms.
affects: All versions
gotchaWhile `SentenceStream` accepts a single string as input, its primary performance benefit comes from processing actual input streams (iterables that yield chunks of text). If you pass a very large single string, the library will still buffer it internally before processing, potentially negating some of the streaming advantages for memory.
fix
For very large texts, provide input as an iterable, such as a file opened in text mode (`open('large_file.txt', 'r', encoding='utf-8')`), or a custom generator that yields text chunks.
affects: All versions
gotchaThe library primarily uses standard English punctuation rules. While robust for many cases, it may not perfectly handle highly ambiguous punctuation, abbreviations, or specific linguistic nuances across all languages without explicit configuration or custom rules.
fix
Review the output for edge cases in your specific text data. For non-English languages or highly specialized texts, consider pre-processing or using language-specific tools.
affects: All versions
Upgrade
Version history
1.3.0latest on PyPI · released Jan 8, 2026
Audit
Dependencies
pythonrequiredRequired for execution
Agent activity
8 hits · last 30 days
node
6
OpenAI (training)
1
Resources
sentence-stream — pip install sentence-stream · libregistry