postprocessors

package
v0.2.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 17, 2025 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package postprocessors provides document content processing implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterDefaults

func RegisterDefaults(r *Registry)

RegisterDefaults registers all built-in processors with the registry. Call this during application initialisation to enable standard processors.

Types

type BuilderFunc

type BuilderFunc func(cfg map[string]any) (driven.PostProcessor, error)

BuilderFunc creates a PostProcessor from generic config. Config is a map of processor-specific settings parsed from user config.

type Pipeline

type Pipeline struct {
	// contains filtered or unexported fields
}

Pipeline chains multiple PostProcessors and runs them in order. It implements the PostProcessorPipeline interface.

func NewPipeline

func NewPipeline(processors ...driven.PostProcessor) *Pipeline

NewPipeline creates a new processing pipeline with the given processors. Processors are executed in the order provided.

func (*Pipeline) Add

func (p *Pipeline) Add(processor driven.PostProcessor)

Add appends a processor to the pipeline.

func (*Pipeline) Len

func (p *Pipeline) Len() int

Len returns the number of processors in the pipeline.

func (*Pipeline) Process

func (p *Pipeline) Process(ctx context.Context, doc *domain.Document) ([]domain.Chunk, error)

Process runs the document through all processors in order. The first processor receives nil chunks and should create them. Subsequent processors receive and may modify the chunks.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry maps processor names to their builders. It allows dynamic construction of processors from configuration.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates a new processor registry.

func (*Registry) Build

func (r *Registry) Build(name string, cfg map[string]any) (driven.PostProcessor, error)

Build creates a processor by name with the given config. Returns error if the processor name is not registered.

func (*Registry) Has

func (r *Registry) Has(name string) bool

Has returns true if a processor with the given name is registered.

func (*Registry) Names

func (r *Registry) Names() []string

Names returns all registered processor names.

func (*Registry) Register

func (r *Registry) Register(name string, builder BuilderFunc)

Register adds a processor builder to the registry. Name should be unique and match the processor's Name() return value.

Directories

Path Synopsis
Package chunker provides a fixed-size text chunking processor.
Package chunker provides a fixed-size text chunking processor.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL