Heratio Framework API Reference

KnowledgeGraphService
in package

Knowledge Graph Service.

Manages the entity relationship graph for heritage discovery. Builds and queries entity co-occurrence networks.

Table of Contents

Methods

addEntity()  : int
Add or update entity node in the graph.
buildCoOccurrenceEdges()  : int
Build co-occurrence edges from entities in an object.
buildFromCache()  : array<string|int, mixed>
Build graph from entity cache.
findNode()  : object|null
Find entity node by value.
getGraphData()  : array<string|int, mixed>
Get graph data for visualization (D3.js format).
getObjectsForEntity()  : array<string|int, mixed>
Get objects containing an entity.
getRelatedEntities()  : array<string|int, mixed>
Get related entities for a node.
getStats()  : array<string|int, mixed>
Get graph statistics.
getTopConnectedEntities()  : array<string|int, mixed>
Get top connected entities.
linkObjectToNode()  : bool
Link an object to a node.
setMinConfidence()  : self
Set minimum confidence threshold.
setMinCoOccurrence()  : self
Set minimum co-occurrence threshold.

Methods

addEntity()

Add or update entity node in the graph.

public addEntity(array<string|int, mixed> $entity) : int
Parameters
$entity : array<string|int, mixed>

Entity data with type, value, actor_id, term_id

Return values
int

Node ID

buildCoOccurrenceEdges()

Build co-occurrence edges from entities in an object.

public buildCoOccurrenceEdges(int $objectId) : int
Parameters
$objectId : int

Information object ID

Return values
int

Number of edges created/updated

buildFromCache()

Build graph from entity cache.

public buildFromCache([int $limit = 5000 ][, bool $rebuild = false ]) : array<string|int, mixed>
Parameters
$limit : int = 5000

Max objects to process

$rebuild : bool = false

If true, clear existing graph first

Return values
array<string|int, mixed>

Build statistics

findNode()

Find entity node by value.

public findNode(string $entityType, string $value) : object|null
Parameters
$entityType : string

Entity type

$value : string

Entity value

Return values
object|null

Node object

getGraphData()

Get graph data for visualization (D3.js format).

public getGraphData([array<string|int, mixed> $filters = [] ][, int $limit = 100 ]) : array<string|int, mixed>
Parameters
$filters : array<string|int, mixed> = []

Filter criteria

$limit : int = 100

Maximum nodes to return

Return values
array<string|int, mixed>

Graph data with nodes and links

getObjectsForEntity()

Get objects containing an entity.

public getObjectsForEntity(int $nodeId[, int $limit = 50 ]) : array<string|int, mixed>
Parameters
$nodeId : int

Node ID

$limit : int = 50

Maximum objects

Return values
array<string|int, mixed>

Object IDs with metadata

getRelatedEntities()

Get related entities for a node.

public getRelatedEntities(int $nodeId[, int $depth = 1 ][, int $limit = 20 ]) : array<string|int, mixed>
Parameters
$nodeId : int

Node ID

$depth : int = 1

Relationship depth (1 = direct, 2 = second degree)

$limit : int = 20

Maximum related entities

Return values
array<string|int, mixed>

Related entities

getStats()

Get graph statistics.

public getStats() : array<string|int, mixed>
Return values
array<string|int, mixed>

getTopConnectedEntities()

Get top connected entities.

public getTopConnectedEntities([string|null $entityType = null ][, int $limit = 20 ]) : array<string|int, mixed>
Parameters
$entityType : string|null = null

Filter by entity type

$limit : int = 20

Maximum entities

Return values
array<string|int, mixed>

Top entities with connection counts

linkObjectToNode()

Link an object to a node.

public linkObjectToNode(int $objectId, int $nodeId[, float $confidence = 1.0 ][, string|null $sourceField = null ][, string $extractionMethod = 'ner' ]) : bool
Parameters
$objectId : int

Information object ID

$nodeId : int

Graph node ID

$confidence : float = 1.0

Confidence score

$sourceField : string|null = null

Source field name

$extractionMethod : string = 'ner'

Extraction method

Return values
bool

Success

setMinConfidence()

Set minimum confidence threshold.

public setMinConfidence(float $confidence) : self
Parameters
$confidence : float
Return values
self

setMinCoOccurrence()

Set minimum co-occurrence threshold.

public setMinCoOccurrence(int $count) : self
Parameters
$count : int
Return values
self

        
On this page

Search results