FunctionSentenceSplitter#

class scikitplot.corpus.FunctionSentenceSplitter(fn, name='custom')[source]#

Wrap any Callable[[str], list[str]] as a SentenceSplitterProtocol.

Parameters:
fnCallable[[str], list[str]]

Sentence-splitting function.

namestr, optional

Human-readable name for logging and repr.

Parameters:

Examples

>>> sp = FunctionSentenceSplitter(lambda t: t.split(". "))
>>> sp.split("Hello. World.")
['Hello', 'World.']
split(text)[source]#

Split text into sentences.

Parameters:
textstr

Input document text.

Returns:
list[str]

Sentence strings.

Raises:
TypeError

If the wrapped callable does not return a list.

Parameters:

text (str)

Return type:

list[str]