Files
semantica/docs/reference/triplet_store.md
T
KaifAhmad1andClaude Sonnet 4.6 946a1089c8 docs: premium redesign — Mintlify v4, dark/cream theme, full module coverage
- Migrate from mint.json to docs.json (Mintlify v4)
- Theme: maple, emerald green + near-black dark / cream light palette
  (#059669 primary, #0A0A0A dark bg, #FAF7F0 light bg)
- Typography: Lexend headings, Inter body
- 5-tab navigation: Documentation, Quick Start, API Reference, Cookbook, FAQ
- Homepage: removed badge stickers, redundant h2, added blockquote tagline,
  full 27-module reference table with semantica.mcp_server added
- quickstart.md: CodeGroup per pipeline step, pattern vs LLM options,
  AccordionGroup for patterns and troubleshooting
- faq.md: full AccordionGroup structure across 5 sections
- reference/explorer.md: NEW — FastAPI explorer, Ontology Hub, Distance
  Intelligence, CLI reference, REST API endpoints
- reference/mcp_server.md: NEW — MCP stdio server, 12 tools with I/O
  examples, 3 resources, Claude Desktop/VS Code/Windsurf/Cline config
- docs.json: explorer added to Output group, mcp_server to Utilities group
- Chat, feedback (thumbs/suggest/raise), OG/Twitter metadata, search topbar
- All reference pages reformatted with Mintlify JSX components

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-22 21:52:50 +05:30

2.6 KiB

title, description, icon
title description icon
Triplet Store Module RDF triple storage with SPARQL queries and bulk loading — Blazegraph, Apache Jena, and RDF4J. table

Store and query RDF triplets with SPARQL support.


Overview

The Triplet Store Module provides W3C-standard RDF storage with full SPARQL query support. Use it when you need semantic web compatibility, OWL reasoning, or SPARQL-based queries.

Backends: Blazegraph, Apache Jena (Fuseki), RDF4J.


Basic Usage

from semantica.triplet_store import TripletStore

store = TripletStore(
    backend="blazegraph",
    endpoint="http://localhost:9999/blazegraph/sparql"
)

# Add triplets
store.add_triplet(
    subject="http://example.org/apple_inc",
    predicate="http://example.org/founded_by",
    obj="http://example.org/steve_jobs"
)

# Bulk load
store.add_triplets_bulk(triplets)

SPARQL Queries

# SELECT query
results = store.sparql("""
    PREFIX ex: <http://example.org/>
    SELECT ?person ?company WHERE {
        ?person ex:founded ?company .
        ?company ex:located_in ex:SiliconValley .
    }
""")

# CONSTRUCT query (returns graph)
graph = store.sparql_construct("""
    PREFIX ex: <http://example.org/>
    CONSTRUCT {
        ?s ex:connected_to ?o
    } WHERE {
        ?s ex:founded ?company .
        ?company ex:has_investor ?o .
    }
""")

Backends

# Blazegraph
store = TripletStore(
    backend="blazegraph",
    endpoint="http://localhost:9999/blazegraph/sparql",
    namespace="semantica"
)

# Apache Jena Fuseki
store = TripletStore(
    backend="jena",
    endpoint="http://localhost:3030/dataset/sparql",
    update_endpoint="http://localhost:3030/dataset/update"
)

# RDF4J
store = TripletStore(
    backend="rdf4j",
    server_url="http://localhost:8080/rdf4j-server",
    repository_id="semantica"
)

Import / Export

# Import from file
store.import_file("ontology.ttl", format="turtle")
store.import_file("data.jsonld", format="json-ld")

# Export to file
store.export("output.ttl", format="turtle")
store.export("output.nt",  format="nt")

See Also

Export to RDF formats. Load OWL ontologies into a triplet store. SPARQL-based reasoning. Property graph alternative for Cypher queries.