Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CleanupChunks ¶
func CleanupChunks(result *ChunkResult) error
CleanupChunks removes the temporary directory and all chunk files
Types ¶
type ChunkConfig ¶
type ChunkConfig struct {
By string // How to split the file: "lines", "bytes", or "tokens"
Size int // Chunk size (e.g., 10000 lines)
Overlap int // Lines/bytes to overlap between chunks for context
MaxChunks int // Limit total chunks to prevent overload
Deduplicate bool // If true, remove near-duplicate chunks after splitting
}
ChunkConfig represents the configuration for chunking a large file
type ChunkResult ¶
type ChunkResult struct {
ChunkPaths []string // Paths to the temporary chunk files
TempDir string // Path to the temporary directory containing the chunks
TotalChunks int // Total number of chunks created
RemovedChunks int // Number of duplicate chunks removed (when Deduplicate is enabled)
}
ChunkResult contains information about the chunking operation
func DeduplicateChunks ¶ added in v0.0.149
func DeduplicateChunks(result *ChunkResult) (*ChunkResult, error)
DeduplicateChunks removes near-duplicate chunks from a ChunkResult. It hashes each chunk's normalized text content using xxhash and removes chunks whose hash has already been seen, keeping the first occurrence. Returns a new ChunkResult with duplicates filtered out.
func SplitFile ¶
func SplitFile(filePath string, config ChunkConfig) (*ChunkResult, error)
SplitFile splits a file into chunks based on the provided configuration It returns the paths to the temporary chunk files and a cleanup function
Click to show internal directories.
Click to hide internal directories.