Documentation
¶
Overview ¶
Package entitygraph implements the entity and source graph runtime. Extraction primitives and dedup logic; Entity/Mention types live in internal/store to avoid a circular import (entitygraph → parser → store).
Index ¶
Constants ¶
const ( MaxAliases = 200 MaxContextLen = 500 MaxEntities = 500 )
Variables ¶
This section is empty.
Functions ¶
func AllowedTypes ¶
func AllowedTypes(packs []domainpacks.Pack) map[string]bool
AllowedTypes returns the set of allowed entity_type values drawn from packs whose Domain == "entity". Vocabulary values are taken from the Aliases of any Field with Key == "entity_type". An empty map means no vocabulary constraint — all entity types declared in frontmatter are accepted.
func Dedup ¶
func Dedup(result *ExtractResult)
Dedup merges duplicate entities in result by (entity_type, canonical_name_normalized). The UUID PK of the first-seen entry is kept so FK references remain stable. Aliases from all duplicate entries are merged (deduplicated, capped at MaxAliases). Mention.EntityID values are rewritten to point to the surviving entity.
func IndexFile ¶
func IndexFile(st EntityWriter, relPath string, res *parser.ParseResult) error
IndexFile extracts entity data from one parsed document and persists it. Called per changed file inside the indexStore loop after metadata upserts.
func NormalizeName ¶
NormalizeName returns a lowercase-trimmed canonical form of name. Internal whitespace runs are collapsed to a single space.
Types ¶
type EntityWriter ¶ added in v0.3.2
type EntityWriter interface {
InsertEntities([]store.Entity) error
InsertEntityMentions([]store.Mention) error
}
EntityWriter is the narrow persistence surface IndexFile needs: just the two entity-graph writes. Depending on this interface (rather than the concrete *store.Store) keeps entitygraph decoupled from the rest of the store API and makes IndexFile trivially mockable. *store.Store satisfies it via the thin forwarders in internal/store/forwarders.go.
type ExtractResult ¶
ExtractResult is the output of extraction from a single ParseResult.
func FromParseResult ¶
func FromParseResult(res *parser.ParseResult, allowedTypes map[string]bool) ExtractResult
FromParseResult extracts entity candidates from a single parsed document. Sources: explicit frontmatter "entities:" list and wikilinks whose targets match entries in allowedTypes (or all wikilinks when allowedTypes is empty). No LLM, network, or file I/O.