API Reference

Full API documentation for TokenBoundaryDetector.

TokenBoundaryDetector

Constructor

TokenBoundaryDetector(
    language: str = 'en',
    min_sentence_length: int = 1,
    abbreviations: Set[str] = None,
    aggressive_abbreviations: bool = False,
    merge_short_sentences: bool = False,
    include_rules: List[int] = None,
    exclude_rules: List[int] = None,
    debug: bool = False
)

Parameters

ParameterTypeDefaultDescription
languagestr'en'Language code
min_sentence_lengthint1Minimum sentence length
abbreviationsSet[str]NoneCustom abbreviations
aggressive_abbreviationsboolFalseStricter abbreviation handling
merge_short_sentencesboolFalseMerge short sentences
include_rulesList[int]NoneUse specific rules
exclude_rulesList[int]NoneExclude specific rules
debugboolFalseEnable debug mode

Methods

split()

detector.split(
    text: str,
    return_spans: bool = False,
    return_metadata: bool = False
) -> Union[List[str], List[tuple], List[dict]]

set_abbreviations()

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

get_abbreviations()

abbrev = detector.get_abbreviations()

explain()

explanations = detector.explain(text)  # Requires debug=True

Exceptions

ExceptionDescription
PySETExceptionBase exception
ConfigurationErrorInvalid configuration
RuleErrorRule evaluation error
LanguageErrorUnsupported language