ProtocolChunkerBridge#
- class scikitplot.corpus.ProtocolChunkerBridge(inner)[source]#
Bridge for any chunker satisfying
ChunkerProtocol(R3-1).A chunker registered in the
ComponentRegistryis checked againstChunkerProtocol(chunk(text, doc_id=None, extra_metadata=None)returning aChunkResult). 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
strategywhen it declares one (aChunkingStrategymember or value), elseCUSTOM: 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
ChunkResultdirectly.DocumentReader.get_documentsnow iterateschunk_result.chunksinstead 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 asextra_metadatato the inner chunker.
- Returns:
- ChunkResult
Ordered list of
Chunkobjects withtext,start_char,end_char, andmetadata.
- Parameters:
- Return type:
Notes
Use
_to_tuplesto convert to the legacylist[tuple[int, str]]format if needed for backward compat.
- strategy: ClassVar[ChunkingStrategy] = 'custom'[source]#