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
| Class | Role |
|---|---|
KnowledgeGraph | Core graph data structure: nodes, edges, properties, temporal validity |
GraphBuilder | Construct from entities + relationships; pass merge_entities=True to enable deduplication |
GraphBuilderWithProvenance | Wraps GraphBuilder with optional provenance tracking; pass provenance=True to enable |
EntityResolver | Entity deduplication and merging during graph construction |
GraphAnalyzer | Unified analytics wrapper: runs centrality, community detection, and connectivity in one call |
ConnectivityAnalyzer | Connected component detection, bridge identification, density, and degree statistics |
TemporalGraphQuery | Point-in-time snapshots, temporal diffs, and all 13 Allen interval queries |
CentralityCalculator | PageRank, degree, betweenness, closeness, eigenvector centrality |
CommunityDetector | Louvain, Leiden, Label Propagation, and K-Clique community detection |
PathFinder | Dijkstra, A*, BFS, and K-Shortest path algorithms |
LinkPredictor | Preferential Attachment, Jaccard, Adamic-Adar link prediction |
NodeEmbedder | Node2Vec structural embeddings for downstream ML |
SimilarityCalculator | Cosine, Euclidean, Manhattan, and correlation similarity scoring |
GraphValidator | Schema and constraint validation before persistence |
GraphBuilder
GraphBuilder constructs knowledge graphs from extracted entities and relationships. merge_entities defaults to False: pass True to enable entity deduplication during construction:
| Method | Returns | Description |
|---|---|---|
build(sources) | dict | Build graph from a dict, list of dicts, or list of entity/relation objects |
build_single_source(data) | dict | Build graph from a single data source dict |
Temporal Knowledge Graphs (v0.4.0)
UseTemporalGraphQuery to attach valid_from/valid_until windows and query point-in-time snapshots of any graph:
- before, after, meets, met_by
- overlaps, overlapped_by
- during, contains, starts, started_by, finishes, finished_by, equals
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.| Method | Best for |
|---|---|
calculate_degree_centrality() | Most-connected nodes |
calculate_pagerank() | Link-based influence (like Google PageRank) |
calculate_betweenness_centrality() | Bottleneck / bridge nodes |
calculate_closeness_centrality() | Nodes closest to all others |
calculate_eigenvector_centrality() | Nodes connected to other high-influence nodes |
Algorithm Summary
| Category | Algorithms | Use Cases |
|---|---|---|
| Node Embeddings | Node2Vec | Structural similarity, node representation |
| Similarity | Cosine, Euclidean, Manhattan, Correlation | Node matching, recommendation |
| Path Finding | Dijkstra, A*, BFS, K-Shortest | Route planning, network analysis |
| Link Prediction | Preferential Attachment, Jaccard, Adamic-Adar | Network completion |
| Centrality | Degree, Betweenness, Closeness, PageRank | Influence analysis |
| Community Detection | Louvain, Leiden, Label Propagation | Social clustering |
| Connectivity | Components, Bridges, Density | Network robustness |
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
