SemanticChunkerBridge#

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

Bridge for SemanticChunker → ChunkerBase contract.

The SemanticChunker (Layer 3) is a new-style chunker that returns ChunkResult objects. This bridge adapts it to the ChunkerBase interface so it can be passed directly to CorpusPipeline and DocumentReader without modification.

SEMANTIC is used as the strategy value. If ChunkingStrategy does not yet define a SEMANTIC member, CUSTOM is used as a fallback so the bridge never raises an AttributeError.

Notes

User note: Pass SemanticChunker(...) directly to CorpusPipeline — the bridge is applied automatically via bridge_chunker.

Developer note: Multilang metadata in chunk.metadata["multilang"] flows through ChunkedTextList to _base.DocumentReader.get_documents which maps it to CorpusDocument fields.

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] = 'semantic'[source]#