semantic

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: MIT Imports: 2 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)
}

Extractor reads a chunk and states what it asserts. The chunk travels with each triple, so every assertion can be traced to its sentence.

type Ingester

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

Ingester reads a reference — a path, a URL, a glob, a string — and returns the documents behind it. It is the only stage that touches the world outside the process.

type Parser

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

Parser reads a document's format and returns the same document with its text made plain and what it learned recorded in Meta.

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. Every stage but the first may be nil; there is nothing to read without an Ingester, so a pipeline without one is an error rather than an empty answer.

type Splitter

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

Splitter cuts a document into chunks small enough to extract from, on boundaries that keep the meaning whole.

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
Package agent holds what an agent knows and what it decided.
Package agent holds what an agent knows and what it decided.
cmd
semantic command
Command semantic runs a pipeline over a reference and prints what it asserted, one tab-separated triple to a line.
Command semantic runs a pipeline over a reference and prints what it asserted, one tab-separated triple to a line.
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 dedupe decides which records are the same thing and which disagree.
Package dedupe decides which records are the same thing and which disagree.
Package export writes a graph out in the formats other tools read.
Package export writes a graph out in the formats other tools read.
Package extract turns text into entities, the relations between them, and the triples those relations assert.
Package extract turns text into entities, the relations between them, and the triples those relations assert.
Package ingest turns a reference — a path, a pattern, a URL, stdin — into documents, and records where every document came from.
Package ingest turns a reference — a path, a pattern, a URL, stdin — into documents, and records where every document came from.
Package kg folds extracted triples into a knowledge graph and answers questions about its shape.
Package kg folds extracted triples into a knowledge graph and answers questions about its shape.
Package normalize is the cleanup between parsing a document and splitting it: the same sentence written with a non-breaking space, a curly apostrophe or a decomposed accent should reach the extractor as one string, not three.
Package normalize is the cleanup between parsing a document and splitting it: the same sentence written with a non-breaking space, a curly apostrophe or a decomposed accent should reach the extractor as one string, not three.
Package ontology is the type system a graph is read through: classes, properties, the domains and ranges that connect them, and the subclass hierarchy over both.
Package ontology is the type system a graph is read through: classes, properties, the domains and ranges that connect them, and the subclass hierarchy over both.
Package parse turns a raw document into text plus the structure the rest of the pipeline needs: section boundaries a splitter can respect, link targets, and — for tabular and tree formats — the decoded value itself.
Package parse turns a raw document into text plus the structure the rest of the pipeline needs: section boundaries a splitter can respect, link targets, and — for tabular and tree formats — the decoded value itself.
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 reason derives the facts a set of triples implies but does not state: what a transitive predicate reaches, what a symmetric or inverse predicate reads backwards, what a class hierarchy entails, and whatever rules a caller writes.
Package reason derives the facts a set of triples implies but does not state: what a transitive predicate reaches, what a symmetric or inverse predicate reads backwards, what a class hierarchy entails, and whatever rules a caller writes.
Package split cuts a document into chunks.
Package split cuts a document into chunks.
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.
qdrant
Package qdrant keeps vectors in Qdrant, over its JSON HTTP API.
Package qdrant keeps vectors in Qdrant, over its JSON HTTP API.
sparql
Package sparql keeps a graph on a SPARQL 1.1 endpoint over HTTP.
Package sparql keeps a graph on a SPARQL 1.1 endpoint over HTTP.

Jump to

Keyboard shortcuts

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