knowledge

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const BaseRules = `
% Auto-map quads to triples (ignoring graph context)
triple(S, P, O) :- quad(S, P, O, _).
`

BaseRules acts as the Datalog schema compatibility layer, mapping quads to triples.

View Source
const DefaultGraph = "default"

DefaultGraph is the default graph name used when parsing N-Triples or when the graph component is missing.

Variables

This section is empty.

Functions

func GetPredicates

func GetPredicates(triples []Triple) []string

GetPredicates extracts unique predicates from a slice of triples.

func ParseNTriples

func ParseNTriples(r io.Reader) ([]string, error)

ParseNTriples reads an N-Triples stream and returns Datalog facts. Format: triple("Subject", "Predicate", "Object")

func SanitizePredicate

func SanitizePredicate(raw string) string

SanitizePredicate cleans up predicates (Shared logic).

func TriplesToFacts

func TriplesToFacts(triples []Triple) []string

TriplesToFacts converts graph triples to Datalog atoms.

Types

type NQuadsLoader

type NQuadsLoader struct{}

NQuadsLoader is a Zero-Dependency parser that handles both N-Triples (.nt) and N-Quads (.nq) formats. It normalizes all entries into Datalog "quad/4" facts, using a default graph for triples.

func NewNQuadsLoader

func NewNQuadsLoader() *NQuadsLoader

NewNQuadsLoader creates a new instance of NQuadsLoader.

func (*NQuadsLoader) GetBaseRules

func (l *NQuadsLoader) GetBaseRules() string

GetBaseRules returns the base Datalog rules associated with this loader.

func (*NQuadsLoader) Parse

func (l *NQuadsLoader) Parse(r io.Reader) ([]string, error)

Parse reads from the given reader and converts N-Triples/N-Quads into Datalog facts. It robustly handles quoted literals containing spaces.

type NTriplesLoader

type NTriplesLoader struct{}

NTriplesLoader is a zero-dependency, high-performance loader for N-Triples data. Deprecated: Use ParseNTriples function instead.

func NewNTriplesLoader

func NewNTriplesLoader() *NTriplesLoader

NewNTriplesLoader creates a new instance of NTriplesLoader.

func (*NTriplesLoader) Parse

func (l *NTriplesLoader) Parse(r io.Reader) ([]string, error)

Parse delegates to ParseNTriples.

type RDFLoader

type RDFLoader struct{}

RDFLoader stub for when rdf build tag is not present.

func NewRDFLoader

func NewRDFLoader() *RDFLoader

NewRDFLoader creates a new instance of RDFLoader stub.

func (*RDFLoader) Parse

func (l *RDFLoader) Parse(path string) ([]string, error)

Parse returns an error indicating RDF support is disabled.

type Triple

type Triple struct {
	Subject   string
	Predicate string
	Object    string
}

Triple represents a raw graph triple.

func ParseGraphFile

func ParseGraphFile(path string) ([]Triple, error)

ParseGraphFile loads triples from .nq, .nt, or .ttl files.

Jump to

Keyboard shortcuts

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