knowledge

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 8 Imported by: 1 module, 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

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 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