WeKnora/internal/infrastructure/chunker
Claude 1585a6f12c feat(chunker): recursive priority splitting + token-aware budget
The Go splitter previously combined all separators into one regex, losing
the priority-based recursive behavior of the Python reference. This pass
walks the separator list in order: the first separator that yields >1
piece wins, mirroring docreader/splitter/splitter.py. Larger semantic
boundaries (\n\n) now win over smaller ones (\n).

Additional cross-cutting changes:
- ChunkingConfig gains Strategy / TokenLimit / Languages fields so the
  per-KB config can pick a tier and pin embedding token budgets.
- buildSplitterConfig in the knowledge service uses the new
  chunker.DefaultChunkSize / DefaultChunkOverlap constants (overlap
  consolidated to 80 ≈ 15%) instead of the previous hardcoded 50.
- ensureDefaults clamps ChunkSize to a per-language character budget
  derived from TokenLimit so chunks stay safe under embedding model
  token caps. Chinese (~1.7 chars/tok) gets a tighter clamp than
  English (~4 chars/tok).

https://claude.ai/code/session_01XADhx6mtu2ZYW3DE9Lun6k
2026-05-06 17:17:07 +08:00
..
header_tracker.go feat(chunker): implement header tracking for Markdown tables during chunking 2026-04-01 13:38:40 +08:00
patterns.go feat(chunker): foundation for adaptive 3-tier chunking 2026-05-06 17:17:07 +08:00
patterns_test.go feat(chunker): foundation for adaptive 3-tier chunking 2026-05-06 17:17:07 +08:00
profiler.go feat(chunker): foundation for adaptive 3-tier chunking 2026-05-06 17:17:07 +08:00
profiler_test.go feat(chunker): foundation for adaptive 3-tier chunking 2026-05-06 17:17:07 +08:00
splitter.go feat(chunker): recursive priority splitting + token-aware budget 2026-05-06 17:17:07 +08:00
splitter_test.go feat(chunker): implement header tracking for Markdown tables during chunking 2026-04-01 13:38:40 +08:00
strategy.go feat(chunker): recursive priority splitting + token-aware budget 2026-05-06 17:17:07 +08:00
strategy_test.go feat(chunker): foundation for adaptive 3-tier chunking 2026-05-06 17:17:07 +08:00
strategy_token_test.go feat(chunker): recursive priority splitting + token-aware budget 2026-05-06 17:17:07 +08:00
tokens.go feat(chunker): foundation for adaptive 3-tier chunking 2026-05-06 17:17:07 +08:00
tokens_test.go feat(chunker): foundation for adaptive 3-tier chunking 2026-05-06 17:17:07 +08:00
validator.go feat(chunker): foundation for adaptive 3-tier chunking 2026-05-06 17:17:07 +08:00