semantic

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2026 License: MIT Imports: 1 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package semantic turns sources into a knowledge graph: ingest, parse, split, extract, then assert. Each stage is one interface with one job; a pipeline is their composition, so a caller may replace any one of them without touching the rest.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chunk

type Chunk struct {
	DocID string
	Index int
	Text  string
}

Chunk is a span of a Doc sized for extraction.

type Doc

type Doc struct {
	ID     string
	Source string
	Text   string
	Meta   map[string]any
}

Doc is one parsed source: its text and where the text came from.

type Extractor

type Extractor interface {
	Extract(context.Context, Chunk) ([]Triple, error)
}

The stages. Each takes the previous stage's value and returns the next.

type Ingester

type Ingester interface {
	Ingest(context.Context, string) ([]Doc, error)
}

The stages. Each takes the previous stage's value and returns the next.

type Parser

type Parser interface {
	Parse(context.Context, Doc) (Doc, error)
}

The stages. Each takes the previous stage's value and returns the next.

type Pipeline

type Pipeline struct {
	Ingest  Ingester
	Parse   Parser
	Split   Splitter
	Extract Extractor
}

Pipeline runs the stages in order. A nil stage is skipped, so a caller that only wants to split does not have to supply an extractor.

func (Pipeline) Run

func (p Pipeline) Run(ctx context.Context, ref string) ([]Triple, error)

Run carries one reference through every stage and returns what was asserted.

type Splitter

type Splitter interface {
	Split(context.Context, Doc) ([]Chunk, error)
}

The stages. Each takes the previous stage's value and returns the next.

type Triple

type Triple struct {
	Subject   string
	Predicate string
	Object    string
	From      Chunk
	Score     float64
}

Triple is one assertion an extractor found, with the span it came from. The span is what makes the assertion answerable later: a claim without its source is not evidence.

Directories

Path Synopsis
cmd
semantic command
Command semantic runs a pipeline over a reference and prints what it asserted.
Command semantic runs a pipeline over a reference and prints what it asserted.
Package decision is the layer the graph exists for: what an agent knew, what it chose, under which rule, and what followed.
Package decision is the layer the graph exists for: what an agent knew, what it chose, under which rule, and what followed.
Package prov records where a value came from, in W3C PROV-O terms: an Entity was generated by an Activity, which was run by an Agent.
Package prov records where a value came from, in W3C PROV-O terms: an Entity was generated by an Activity, which was run by an Agent.
Package store holds the three ways a graph is kept: by similarity, by edge, and by assertion.
Package store holds the three ways a graph is kept: by similarity, by edge, and by assertion.

Jump to

Keyboard shortcuts

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