Reputation: 168
The current ttl file contains ontology data.
I referred the following link: Import RDF (XML or Turtle) into Neo4j but it didn't help.
The part is taken from the ttl file.
http://www.semanticweb.org/hp/ontologies/2017/4/untitled-ontology-87#abrasives http://www.semanticweb.org/hp/ontologies/2017/4/untitled-ontology-87#abrasives rdf:type owl:Class .
As this is an ongoing project, I want to upload the current file data to Neo4j and to create an interface for queries. Any other database or workarounds are welcomed.
Thank you.
Upvotes: 1
Views: 1410
Reputation: 991
Since 2023 there is a python package rdflib-neo4j that allows you to use Neo4j as a triple store for RDFLib. Here's an example currently shown in the README:
from rdflib_neo4j import Neo4jStoreConfig, Neo4jStore, HANDLE_VOCAB_URI_STRATEGY
from rdflib import Graph
# set the configuration to connect to your Aura DB
AURA_DB_URI="your_db_uri"
AURA_DB_USERNAME="neo4j"
AURA_DB_PWD="your_db_pwd"
auth_data = {'uri': AURA_DB_URI,
'database': "neo4j",
'user': AURA_DB_USERNAME,
'pwd': AURA_DB_PWD}
# Define your custom mappings & store config
config = Neo4jStoreConfig(auth_data=auth_data,
custom_prefixes=prefixes,
handle_vocab_uri_strategy=HANDLE_VOCAB_URI_STRATEGY.IGNORE, batching=True)
file_path = 'https://github.com/jbarrasa/gc-2022/raw/main/search/onto/concept-scheme-skos.ttl'
# Create the RDF Graph, parse & ingest the data to Neo4j, and close the store(If the field batching is set to True in the Neo4jStoreConfig, remember to close the store to prevent the loss of any uncommitted records.)
neo4j_aura = Graph(store=Neo4jStore(config=config))
# Calling the parse method will implictly open the store
neo4j_aura.parse(file_path, format="ttl")
neo4j_aura.close(True)
Upvotes: 1
Reputation: 20185
Your best bet is to use the neosemantics plugin, which is especially designed to import rdf type data into Neo4j.
https://github.com/jbarrasa/neosemantics
Upvotes: 2