cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Linking ontology to an existing label property graph

somasays
Node Link

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

  1. Create Ontology using cypher Reference here
  2. Data already exists in the neo4j desktop
  3. Init configuration 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

1 ACCEPTED SOLUTION

  1. yes
  2. you don't need a graphconfig to export a native property graph as RDF. It should just work.
  3. you can publish the native property graph ontology by running :GET http://localhost:7474/rdf/neo4j/onto It's basically an owl serialisation of call db.schema.visualization()
    3.a if you want to publish your property graph data according to a different model (a public one) then you need to define mappings but you don't need to import the ontology
    3.b if you want to run inferencing, then you need to import the ontology via 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

View solution in original post

5 REPLIES 5

somasays
Node Link

What I'm trying to achieve here is.

  1. Have an ontology defined for the data model that is already present as a Label property graph
  2. Validate the data ingested by ETL against the ontology
  3. Have some relation mapped between the ontology and the label property graph, so the exported rdf is based on the defined ontology(I'm not so clear about this still)

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.

somasays
Node Link

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

  1. SHACL shall be enough for validation
  2. Configure graphconfig with handleVocabUris as IGNORE to export the property graph as RDF
    is this correct?
  3. In case we want to publish Ontology for internal systems, we create them as RDF/OWL documents and import them into neosemantics, but this has no impact/influence on the existing property graph or any updates performed on it

Regards,
Soma

  1. yes
  2. you don't need a graphconfig to export a native property graph as RDF. It should just work.
  3. you can publish the native property graph ontology by running :GET http://localhost:7474/rdf/neo4j/onto It's basically an owl serialisation of call db.schema.visualization()
    3.a if you want to publish your property graph data according to a different model (a public one) then you need to define mappings but you don't need to import the ontology
    3.b if you want to run inferencing, then you need to import the ontology via 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

somasays
Node Link

Thank you that clarifies things for me.