load_sample_text

data.load_sample_text(doc_id=None, *, filename=_DEFAULT_SAMPLE)

Return a single (doc_id, text) pair from the bundled sample corpus.

Parameters

Name Type Description Default
doc_id str Specific document ID to retrieve. If None, returns the first available text. None
filename str Name of the pickled corpus file to load. _DEFAULT_SAMPLE

Returns

Name Type Description
tuple[str, str] Document ID and text content.

Raises

Name Type Description
ValueError If the requested doc_id is not found in the corpus.
RuntimeError If the corpus is empty.

Examples

>>> from moodswing.data import load_sample_text, list_sample_texts
>>> # See what's available
>>> print(list_sample_texts())
>>> # Load a specific text
>>> doc_id, text = load_sample_text("madame_bovary")