Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
04-20-2021 12:01 AM
I'm trying to export an existing Label property graph in neo4j as RDF and trying to use neosemantics for that purpose and for the sake of PoC, I tried to use the example database with Movie dataset that comes preinstalled with Neo4j desktop.
Below are the steps I followed
CALL n10s.graphconfig.init();
Pretty much that's it. I'm pretty sure I have missed some steps and reading the docs could give me some hint, but I thought to ask here as well to get a direction so as to speed up a bit.
I can access the Ontology using :GET http://localhost:7474/rdf/neo4j/onto
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
<neo4j://graph.schema#WROTE> a owl:ObjectProperty;
rdfs:range <neo4j://graph.schema#Movie>;
rdfs:domain <neo4j://graph.schema#Person>;
rdfs:label "WROTE" .
<neo4j://graph.schema#RANGE> a owl:ObjectProperty;
rdfs:range <neo4j://graph.schema#Class>;
rdfs:domain <neo4j://graph.schema#ObjectProperty>;
rdfs:label "RANGE" .
<neo4j://graph.schema#ACTED_IN> a owl:ObjectProperty;
rdfs:label "ACTED_IN";
rdfs:domain <neo4j://graph.schema#Person>;
rdfs:range <neo4j://graph.schema#Movie> .
........
I can validate the Label property graph against the Ontology using Cypher like this
// DatatypeProperty domain semantics meta-rule
MATCH (n:Class)<-[:DOMAIN]-(p:DatatypeProperty)
WITH DISTINCT n.uri as classUri, n.label as classLabel, p.uri as prop, p.label as propLabel
MATCH (x) WHERE x[propLabel] IS NOT NULL AND NOT classLabel IN labels(x)
RETURN id(x) AS nodeUID,
'domain of ' + propLabel + ' [' + prop + ']' AS `check failed`,
'Node labels: (' + reduce(s = '', l IN Labels(x) | s + ' ' + l) + ') should include ' + classLabel AS extraInfo
But what I cannot do is access the data as RDF, like for example
:POST /rdf/neo4j/cypher
{ "cypher" :"match (m: Movie)<-[:ACTED_IN]-(actor: Person) match (m)<-[:DIRECTED]-(director: Person) where m.title = 'The Matrix' RETURN m, actor, director", "format": "RDF/XML"}
returns Empty
<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
</rdf:RDF>
Any pointers will be highly appreciated.
Thanks
Solved! Go to Solution.
04-22-2021 06:19 AM
:GET http://localhost:7474/rdf/neo4j/onto
It's basically an owl serialisation of call db.schema.visualization()
call n10s.onto.import.*
and it has to be an OWL or RDFS ontology.also to the previous question, mappings can also be used for import. If you want the vocabulary mapping to be applied when importing an RDF dataset.
hope this helps?
JB
04-20-2021 12:59 AM
What I'm trying to achieve here is.
04-20-2021 01:31 AM
Hi @somasays , here are some comments:
If what you want to do is validate your model against some constraints, what you need is a SHACL definition of the shape of your graph. You can find examples of using it in this video too.
Ontologies serve a different purpose. An ontology is used to run inferences to derive new information from the existing one. More details here.
In the steps you describe in your previous message you seem to be mixing different things. The cypher definition of the ontology is an old one that was created for the sole purpose of illustrating the blog post. I would recommend you create an ontology in OWL or RDFS and import it using n10s.onto.import.*
I hope this helps. Let us know how you get on.
Cheers,
JB.
04-22-2021 02:51 AM
Thanks @jesus.barrasa , This was helpful. I'm a novice so obviously have some confusion.
Just to clarify some underlying principle,
"will the Ontology mapping with neosemantics be useful (almost)only when mapping a graph with a public vocabulary(or vocabulary other than the schema of the graph)?"
Our data already exists in Neo4J as Label property graph and in this case
Regards,
Soma
04-22-2021 06:19 AM
:GET http://localhost:7474/rdf/neo4j/onto
It's basically an owl serialisation of call db.schema.visualization()
call n10s.onto.import.*
and it has to be an OWL or RDFS ontology.also to the previous question, mappings can also be used for import. If you want the vocabulary mapping to be applied when importing an RDF dataset.
hope this helps?
JB
04-22-2021 06:47 AM
Thank you that clarifies things for me.
All the sessions of the conference are now available online