semantica.kg transforms extracted entities and relationships into structured, queryable knowledge graphs:
- Temporal nodes and edges with
valid_from/valid_untilwindows 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
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.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
Similarity Scoring
SimilarityCalculator computes cosine, Euclidean, Manhattan, and correlation similarity between node embeddings:
Graph Analytics
- Centrality
- Community Detection
- Path Finding
- Link Prediction
- Node Embeddings
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: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
- Building Knowledge Graphs: fundamentals of KG construction · Beginner
- Your First Knowledge Graph: entity extraction to visualization · Beginner
- Graph Analytics: centrality and community detection · Intermediate
- Advanced Graph Analytics: PageRank, Louvain, shortest path · Advanced
- Temporal Knowledge Graphs: temporal logic and graph evolution · Advanced
