semantica.kg transforms extracted entities and relationships into structured, queryable knowledge graphs:
  • Temporal nodes and edges with valid_from / valid_until windows and all 13 Allen interval relations
  • Full graph analytics suite: centrality, community detection, path finding, link prediction
  • Node2Vec structural embeddings for downstream ML and similarity scoring
  • OWL-Time export and versioned snapshots via TemporalVersionManager
  • Schema and constraint validation before persistence

Exported Classes

For conflict detection and advanced entity resolution, use semantica.conflicts and semantica.deduplication alongside this module.
Knowledge graph entity and relation structure: Person, Organization, Location, Date nodes with typed labeled edges

GraphBuilder

GraphBuilder constructs knowledge graphs from extracted entities and relationships. merge_entities defaults to False: pass True to enable entity deduplication during construction:

Temporal Knowledge Graphs (v0.4.0+)

Full temporal reference including BiTemporalFact, TemporalReasoningEngine, Allen interval algebra, and TemporalNormalizer is covered in the dedicated Temporal Intelligence page. This section documents the KG-layer temporal API.
The temporal stack — see the Temporal Intelligence page for the full reference.

Building a Temporal Graph

Point-in-Time Queries

TemporalGraphQuery accepts optional constructor args; pass the graph into each query call:

Bi-Temporal Facts

BiTemporalFact is a dataclass — use the from_relationship() factory, not a positional constructor:

Allen Interval Algebra

TemporalReasoningEngine implements all 13 Allen relations deterministically — no LLM, no probability. It operates on TemporalInterval objects (not plain dicts):

Natural Language Temporal Parsing

Versioned Snapshots

See the Temporal Intelligence reference for the full class API, domain examples (personnel changes, policy evolution, financial timelines), and configuration options.

Similarity Scoring

SimilarityCalculator computes cosine, Euclidean, Manhattan, and correlation similarity between node embeddings:

Graph Analytics

Measure node importance across five algorithms. Use calculate_all_centrality() to run them all at once.

Algorithm Summary

GraphValidator

Validates graph structure: checks required fields, duplicate IDs, dangling edges, and optionally detects cycles and orphan nodes:
Pass strict=True to treat warnings as errors. Pass a schema dict with "entity_types" and "relationship_types" keys to validate against a known type vocabulary.

Configuration

  • Graph Store — Persist graphs in Neo4j, FalkorDB, or Apache AGE.
  • Semantic Extract — Source of entities and relationships fed to GraphBuilder.
  • Visualization — Visualize knowledge graphs interactively.
  • Conflicts — Conflict detection and resolution.

Cookbooks