Quick Start

Get up and running with PySET in 5 minutes.

Installation

pip install pyset

Basic Usage

from pyset import TokenBoundaryDetector

detector = TokenBoundaryDetector()
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!"]

Return Options

Get Character Spans

spans = detector.split(text, return_spans=True)
# Returns: [(0, 13), (14, 29), ...]

Get Metadata

info = detector.split(text, return_metadata=True)
# Returns: [{'text': 'Hello world.', 'start': 0, 'end': 13, 'confidence': 1.0}, ...]

Common Patterns

Multiple Paragraphs

text = """This is the first paragraph.

This is the second paragraph. It has multiple sentences.
The final sentence here."""

sentences = detector.split(text)

Custom Abbreviations

detector.set_abbreviations({'CEO', 'CFO', 'CTO', 'Inc', 'Ltd'})

Aggressive Mode

detector = TokenBoundaryDetector(aggressive_abbreviations=True)

Debug Mode

detector = TokenBoundaryDetector(debug=True)
explanations = detector.explain("Mr. Smith went to the store.")
# Shows which rules were applied

Next Steps