mirror of
https://github.com/semantica-agi/semantica.git
synced 2026-09-15 04:00:33 +00:00
- Replace mock data with real feed URLs, APIs, and database patterns - Add real threat intelligence feeds (CISA, US-CERT, Security Week, Dark Reading) - Add real financial feeds (Reuters, CNN Money, Bloomberg, Financial Times) - Add real healthcare feeds (CDC, WHO) - Add real API endpoints (MITRE ATT&CK, NVD CVE API, Polygon.io, Alpha Vantage, FHIR APIs) - Add realistic database connection patterns with SQL queries - Add Kafka/RabbitMQ streaming configurations - Update all cybersecurity notebooks (5/5) with real sources - Update finance notebooks (2/2) with real sources - Update healthcare notebooks (1/1) with real sources - Create REAL_DATA_SOURCES.md documentation - Improve error handling with try-except blocks - Add batch processing for multiple feed URLs
5.8 KiB
5.8 KiB
In [ ]:
from semantica.export import (
JSONExporter,
RDFExporter,
CSVExporter,
GraphExporter,
OWLExporter,
VectorExporter
)
from semantica.kg import GraphBuilder
from semantica.embeddings import EmbeddingGenerator
from semantica.ontology import OntologyGenerator
import os
os.makedirs("exports", exist_ok=True)
In [ ]:
builder = GraphBuilder()
entities = [
{"id": "e1", "type": "Person", "name": "Alice", "properties": {"age": 30}},
{"id": "e2", "type": "Person", "name": "Bob", "properties": {"age": 35}},
{"id": "e3", "type": "Organization", "name": "Tech Corp", "properties": {"founded": 2010}},
]
relationships = [
{"source": "e1", "target": "e2", "type": "knows"},
{"source": "e1", "target": "e3", "type": "works_for"},
]
knowledge_graph = builder.build(entities, relationships)
embedding_generator = EmbeddingGenerator()
texts = [e["name"] for e in entities]
embeddings = embedding_generator.generate(texts)
ontology_generator = OntologyGenerator()
ontology = ontology_generator.generate_from_graph(knowledge_graph)
In [ ]:
json_exporter = JSONExporter()
json_exporter.export(knowledge_graph, "exports/output.json")
In [ ]:
rdf_exporter = RDFExporter()
rdf_exporter.export(knowledge_graph, "exports/output.rdf")
In [ ]:
csv_exporter = CSVExporter()
csv_exporter.export(knowledge_graph, "exports/output.csv")
In [ ]:
graph_exporter = GraphExporter()
graph_exporter.export(knowledge_graph, "exports/output.graphml", format="graphml")
graph_exporter.export(knowledge_graph, "exports/output.gexf", format="gexf")
In [ ]:
owl_exporter = OWLExporter()
owl_exporter.export(ontology, "exports/output.owl")
In [ ]:
vector_exporter = VectorExporter()
vector_exporter.export(embeddings, "exports/output.vectors")
In [ ]:
export_files = [
"exports/output.json",
"exports/output.rdf",
"exports/output.csv",
"exports/output.graphml",
"exports/output.gexf",
"exports/output.owl",
"exports/output.vectors"
]
for file in export_files:
if os.path.exists(file):
size = os.path.getsize(file)
print(f"{file} ({size} bytes)")