Coverage for src/qdrant_loader/core/chunking/strategy/markdown/splitters/fallback.py: 100%
17 statements
« prev ^ index » next coverage.py v7.10.6, created at 2025-09-08 06:05 +0000
« prev ^ index » next coverage.py v7.10.6, created at 2025-09-08 06:05 +0000
1"""Fallback splitter implementation extracted from `section_splitter`."""
3import re
5from qdrant_loader.core.chunking.strategy.markdown.splitters.base import BaseSplitter
8class FallbackSplitter(BaseSplitter):
9 """Simple fallback splitter for when other strategies fail."""
11 def split_content(self, content: str, max_size: int) -> list[str]:
12 """Simple chunking implementation based on fixed size.
14 Args:
15 content: Content to split
16 max_size: Maximum chunk size
18 Returns:
19 List of content chunks
20 """
21 chunks: list[str] = []
23 paragraphs = re.split(r"\n\s*\n", content)
24 current_chunk = ""
26 for para in paragraphs:
27 if len(current_chunk) + len(para) <= max_size:
28 current_chunk += para + "\n\n"
29 else:
30 if current_chunk:
31 chunks.append(current_chunk.strip())
32 current_chunk = para + "\n\n"
34 if current_chunk:
35 chunks.append(current_chunk.strip())
37 return chunks
40__all__ = ["FallbackSplitter"]