ProtocolChunkerBridge#

class scikitplot.corpus.ProtocolChunkerBridge(inner)[source]#

Bridge for any chunker satisfying ChunkerProtocol (R3-1).

A chunker registered in the ComponentRegistry is checked against ChunkerProtocol (chunk(text, doc_id=None, extra_metadata=None) returning a ChunkResult). This bridge lets every such chunker run in the pipeline; a class with a specific bridge (or a subclass of one) gets that bridge instead.

Notes

The strategy is the inner chunker’s own strategy when it declares one (a ChunkingStrategy member or value), else CUSTOM: nothing is known about the boundaries a third-party chunker draws.

Parameters:

inner (Any)

chunk(text, metadata=None)[source]#

Chunk text and return a ChunkResult.

CRITICAL-02 (Phase 2): Returns ChunkResult directly. DocumentReader.get_documents now iterates chunk_result.chunks instead of (char_start, chunk_text) tuples.

Parameters:
textstr

Raw text to chunk.

metadatadict[str, Any] or None, optional

Raw-chunk metadata dict passed by get_documents(). Forwarded as extra_metadata to the inner chunker.

Returns:
ChunkResult

Ordered list of Chunk objects with text, start_char, end_char, and metadata.

Parameters:
Return type:

ChunkResult

Notes

Use _to_tuples to convert to the legacy list[tuple[int, str]] format if needed for backward compat.

strategy: ClassVar[ChunkingStrategy] = 'custom'[source]#