semantic

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 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.
bench
locomo command
Command locomo runs the LoCoMo long-conversation recall benchmark over two memories built from the same package: turns in a vector store, and a graph of who said what about whom.
Command locomo runs the LoCoMo long-conversation recall benchmark over two memories built from the same package: turns in a vector store, and a graph of who said what about whom.
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.
examples
agent command
Command agent is a credit desk that has to answer for itself.
Command agent is a credit desk that has to answer for itself.
conflicts command
Command conflicts finds where documents disagree and settles the disagreements it can.
Command conflicts finds where documents disagree and settles the disagreements it can.
coref command
Command coref resolves the words in a text that point at the same thing.
Command coref resolves the words in a text that point at the same thing.
dedupe command
Command dedupe decides which records are the same thing.
Command dedupe decides which records are the same thing.
drivers command
Command drivers is the set of stores semantica knows about, and what each name means.
Command drivers is the set of stores semantica knows about, and what each name means.
export command
Command export writes one graph in every format this module carries, and reads back the ones that can be read back.
Command export writes one graph in every format this module carries, and reads back the ones that can be read back.
extract command
Command extract turns text into entities, the relations between them, and the triples those relations assert.
Command extract turns text into entities, the relations between them, and the triples those relations assert.
ingest command
Command ingest turns references into documents.
Command ingest turns references into documents.
kg command
Command kg folds assertions into a knowledge graph and asks what shape it is.
Command kg folds assertions into a knowledge graph and asks what shape it is.
normalize command
Command normalize is the cleanup between parsing a document and splitting it.
Command normalize is the cleanup between parsing a document and splitting it.
ontology command
Command ontology reads a schema off data that has already been observed, writes it out as OWL, and reads it back.
Command ontology reads a schema off data that has already been observed, writes it out as OWL, and reads it back.
parse command
Command parse reads six formats — markdown, HTML, JSON, CSV, XML, email — and shows what each one recovers beyond the text: the sections a splitter can cut on, the links, the document's own metadata, and the decoded value for the formats that have one.
Command parse reads six formats — markdown, HTML, JSON, CSV, XML, email — and shows what each one recovers beyond the text: the sections a splitter can cut on, the links, the document's own metadata, and the decoded value for the formats that have one.
pipeline command
Command pipeline carries one document through every stage — ingest, parse, normalize, split, extract, fold into a graph, write it out — and prints what crossed each seam.
Command pipeline carries one document through every stage — ingest, parse, normalize, split, extract, fold into a graph, write it out — and prints what crossed each seam.
prov command
Command prov records where every claim came from, in W3C PROV-O terms: an Entity was generated by an Activity, which was run by an Agent.
Command prov records where every claim came from, in W3C PROV-O terms: an Entity was generated by an Activity, which was run by an Agent.
reason command
Command reason derives the facts a set of triples implies but does not state.
Command reason derives the facts a set of triples implies but does not state.
split command
Command split cuts one document nine ways and shows what each splitter is for.
Command split cuts one document nine ways and shows what each splitter is for.
store command
Command store uses the three ways a graph is kept — by similarity, by edge, by assertion — and they are three interfaces because they answer three questions: what is like this, what is connected to this, what was asserted.
Command store uses the three ways a graph is kept — by similarity, by edge, by assertion — and they are three interfaces because they answer three questions: what is like this, what is connected to this, what was asserted.
temporal command
Command temporal is the graph asked how it stood, not how it stands.
Command temporal is the graph asked how it stood, not how it stands.
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