Skip to main content

PySET - Python Sentence Extraction Toolkit. High-performance, zero-dependency sentence boundary detection.

Project description

PySET - Python Sentence Extraction Toolkit

PyPI Version Python Versions License

Logo

Python Sentence Extraction Toolkit is a high-performance, zero-dependency, modern sentence boundary detection library designed to break down any provided text into indivdual sentences to be used as required. It was intially buildt to fill the need for a efficient modern system to break down sentences in text for form co-hearent chunks when indexing into a vector database but it has a wide range of applicaitons.

Built for Python 3.14

Features

  • 85 intelligent rules for accurate sentence splitting
  • 52 languages supported
  • Zero dependencies (pure Python standard library)
  • 2-3x faster than comparable libraries
  • More accurate on complex legal documents
  • Extensible design for custom rules

Installation

pip install pysentence-extraction-toolkit

Quick Start

from pyset import TokenBoundaryDetector

detector = TokenBoundaryDetector()

# Simple usage
text = "Hello world. How are you? I'm doing great!"
sentences = detector.split(text)

print(sentences)
# ['Hello world.', 'How are you?', "I'm doing great!"]

Performance

Based on internal benchmarks vs PySBD:

Text Size Words PySET PySBD Speedup
Sentences ~5 0.05ms 0.10ms 2.0x
Paragraph ~104 0.60ms 1.37ms 2.3x
Article ~484 2.41ms 5.25ms 2.2x
Document ~1400 5.68ms 21.95ms 3.9x

PySET processes 158,000+ words/second vs 63,000 for PySBD.

chart chart

Why PySET?

  • Zero dependencies - No external packages required
  • 85 rules handling edge cases like abbreviations, URLs, emails, decimals, quotes
  • Accurate - Priority-based rule evaluation for correct decisions
  • Fast - Pre-compiled patterns and optimized algorithms
  • Extensible - Easy to add custom rules
  • Well tested - 100% accuracy on 52 languages

Configuration Options

Parameter Type Default Description
language str 'en' Language code
min_sentence_length int 1 Minimum sentence length
aggressive_abbreviations bool False Stricter abbreviation handling
merge_short_sentences bool False Merge short sentences
include_rules List[int] None Use specific rules
exclude_rules List[int] None Exclude specific rules
debug bool False Enable debug logging

Use Cases

  • Document chunking for LLMs and RAG systems
  • Text preprocessing for NLP pipelines
  • Legal document analysis
  • News article segmentation
  • Academic paper processing
  • Content extraction and cleaning

Documentation

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/

# Run with coverage
pytest tests/ --cov=pyset

License

MIT License - See LICENSE file for details.


PySET - Python Sentence Extraction Toolkit Accurate. Fast. Zero Dependencies.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pysentence_extraction_toolkit-1.1.1.tar.gz (1.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pysentence_extraction_toolkit-1.1.1-py3-none-any.whl (841.5 kB view details)

Uploaded Python 3

File details

Details for the file pysentence_extraction_toolkit-1.1.1.tar.gz.

File metadata

File hashes

Hashes for pysentence_extraction_toolkit-1.1.1.tar.gz
Algorithm Hash digest
SHA256 0810db0e8762f4f331cccbc59ccd2c4af2f8cfe8773e2aa1c832efd2d41109ce
MD5 5cede0dd7463c2ff315b57c5ab3dea3f
BLAKE2b-256 afbedcaab76be3b2caf1242b9551a0551453af8ae3cae700268f8a18489e46c0

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysentence_extraction_toolkit-1.1.1.tar.gz:

Publisher: build.yml on CosmonautCode/PySentence-Extraction-Toolkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pysentence_extraction_toolkit-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for pysentence_extraction_toolkit-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 93df4d79454b1becd6a79811c596c5d7216b805a58e419cca673c019d40acb83
MD5 991ecca3d63fcb569bb314442d996495
BLAKE2b-256 a427b539a5ce287896ca47d580ab448d89bc29fd4c635653e01bc6b88e64179c

See more details on using hashes here.

Provenance

The following attestation bundles were made for pysentence_extraction_toolkit-1.1.1-py3-none-any.whl:

Publisher: build.yml on CosmonautCode/PySentence-Extraction-Toolkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page