Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSplitter ¶
NewSplitter create a recursive splitter.
Types ¶
type Config ¶
type Config struct {
ChunkSize int
// OverlapSize is the maximum allowed overlapping length between chunks. Overlapping can mitigate loss of information when context is divided.
OverlapSize int
// Separators are sequentially used to split text.
// When the current separator cannot split the text into a size smaller than ChunkSize, the next separator will be used to attempt to split until the chunk size is smaller than ChunkSize or there are no separator available.
// ["\n", ".", "?", "!"] by default.
Separators []string
// LenFunc is used to calculate string length. Use builtin function len() by default.
LenFunc func(string) int
// KeepType specifies if separator will be kept in split chunks. Discard separator by default.
KeepType KeepType
// IDGenerator is an optional function to generate new IDs for split chunks.
// If nil, the original document ID will be used for all splits.
IDGenerator IDGenerator
}
type IDGenerator ¶
IDGenerator generates new IDs for split chunks
Click to show internal directories.
Click to hide internal directories.