binder

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnboundArgument = errors.New("unbound argument")

Functions

This section is empty.

Types

type BindInput

type BindInput struct {
	Previous      core.QueryEvent
	Template      core.Template
	ContextValues map[string]string
	ContextTypes  map[string]string
	ContextRaw    map[string]any
	RecentValues  map[string]string
	RecentTypes   map[string]string
	RecentRaw     map[string]any
}

type BoundArg

type BoundArg struct {
	Position          int
	Name              string
	Value             string
	Type              string
	Raw               any
	Source            Source
	SourceArgPosition int
	Confidence        float64
}

type BoundQuery

type BoundQuery struct {
	TemplateID  core.TemplateID
	Args        []core.ArgValue
	BoundArgs   []BoundArg
	Confidence  float64
	RuleSuccess int
}

type Config

type Config struct {
	MinTrials           int
	ConfidenceThreshold float64
	MaxRules            int
}

type Learner

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

func New

func New(cfg Config) *Learner

func (*Learner) Bind

func (l *Learner) Bind(prev core.QueryEvent, tmpl core.Template) (BoundQuery, error)

func (*Learner) BindPlan

func (l *Learner) BindPlan(input BindInput) (BoundQuery, error)

func (*Learner) ObserveTransition

func (l *Learner) ObserveTransition(prev core.QueryEvent, curr core.QueryEvent)

func (*Learner) Restore

func (l *Learner) Restore(snapshot Snapshot) error

func (*Learner) RulesLearned

func (l *Learner) RulesLearned() int

func (*Learner) Snapshot

func (l *Learner) Snapshot() Snapshot

type Rule

type Rule struct {
	FromTemplate core.TemplateID
	ToTemplate   core.TemplateID
	TargetArg    int
	SourceArg    int
	Trials       int
	Successes    int
	LastSeen     uint64
}

func (Rule) Confidence

func (r Rule) Confidence() float64

type Snapshot

type Snapshot struct {
	Rules []Rule
	Clock uint64
}

type Source

type Source string
const (
	SourceContextValue   Source = "context_value"
	SourcePreviousArg    Source = "previous_arg"
	SourceRecentSemantic Source = "recent_semantic_value"
)

Jump to

Keyboard shortcuts

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