entity

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEntityContext

func GetEntityContext(db *sql.DB, name string) (string, error)

GetEntityContext returns description for an entity (for Zozi's context)

func GetRelationships

func GetRelationships(db *sql.DB, entityName string) ([]string, error)

GetRelationships returns all relationships for an entity

func IngestEntities

func IngestEntities(db *sql.DB, graph *EntityGraph) error

IngestEntities loads entities.yaml into the database

Types

type AliasMatch

type AliasMatch struct {
	Alias      string
	EntityName string
	EntityType string
	Note       string
}

AliasMatch represents a found alias and its canonical entity

func ExpandQuery

func ExpandQuery(db *sql.DB, query string) (string, []AliasMatch, error)

ExpandQuery replaces aliases with canonical names and adds context. Sorts matches by alias length (longest first) to prevent partial corruption (e.g., "the tree" must be replaced before "tree" gets a chance).

func LookupAliases

func LookupAliases(db *sql.DB, query string) ([]AliasMatch, error)

LookupAliases finds all entity aliases mentioned in the query. Uses word boundaries for ASCII aliases to prevent substring false positives (e.g., alias "AB" must not match inside "ABC").

type Entity

type Entity struct {
	Name        string   `yaml:"name"`
	Type        string   `yaml:"type"`
	Aliases     []string `yaml:"aliases"`
	Description string   `yaml:"description"`
}

Entity represents a person, part, animal, or concept in Alice's world

type EntityGraph

type EntityGraph struct {
	Entities      []Entity       `yaml:"entities"`
	Relationships []Relationship `yaml:"relationships"`
}

EntityGraph holds the complete ground truth map

func LoadEntityGraph

func LoadEntityGraph(path string) (*EntityGraph, error)

LoadEntityGraph reads and parses entities.yaml

type EntityStats

type EntityStats struct {
	TotalEntities      int
	TotalAliases       int
	TotalRelationships int
	ByType             map[string]int
}

EntityStats returns counts for reporting

func GetEntityStats

func GetEntityStats(db *sql.DB) (*EntityStats, error)

type Relationship

type Relationship struct {
	From        string `yaml:"from"`
	To          string `yaml:"to"`
	Type        string `yaml:"type"`
	Description string `yaml:"description"`
}

Relationship represents a connection between two entities

Jump to

Keyboard shortcuts

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