entity

package
v2.3.4 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package entity implements entity extraction and linking for Cortex.

It extracts files, URLs, packages, symbols, and concepts from observation content using regex patterns and stores them as entity links.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Extract

func Extract(obs *domain.Observation) []*domain.EntityLink

Extract extracts all entity links from an observation's content.

func Normalize

func Normalize(entityType, value string) string

Normalize returns a deterministic canonical key. It deliberately performs no fuzzy/LLM matching: lower-casing, Unicode space folding and punctuation removal are safe, repeatable operations suitable for blocking and dedup.

Types

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service handles entity extraction and storage.

func NewService

func NewService(repo domain.EntityRepository) *Service

NewService creates a new entity service.

func (*Service) ExtractAndSave

func (s *Service) ExtractAndSave(ctx context.Context, obs *domain.Observation) error

ExtractAndSave extracts entities from an observation and saves the links.

func (*Service) ExtractAndSaveInTx

func (s *Service) ExtractAndSaveInTx(ctx context.Context, handle any, obs *domain.Observation) error

ExtractAndSaveInTx performs extraction using the transaction already enlisted by the caller's UnitOfWork. It never opens an autocommit transaction.

func (*Service) FindByEntity

func (s *Service) FindByEntity(ctx context.Context, entityType, entityValue string) ([]*domain.EntityLink, error)

FindByEntity returns observations referencing a specific entity.

func (*Service) GetByObservation

func (s *Service) GetByObservation(ctx context.Context, obsID int64) ([]*domain.EntityLink, error)

GetByObservation returns entity links for an observation.

Jump to

Keyboard shortcuts

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