neo4j-labs / neosemantics

Graph+Semantics: Import/Export RDF from Neo4j. SHACL Validation, Model mapping and more.... If you like it, please ★ ⇧
https://neo4j.com/labs/neosemantics/
Apache License 2.0
817 stars 143 forks source link

How to get the rdf:type of an instance? #65

Open masium opened 5 years ago

masium commented 5 years ago

Hi Jesus,

I have a sample ontology that contains classes and instances, modeled in Protege:

screen shot 2019-01-10 at 10 59 22 am

I import the RDF into neo4j using:

CALL semantics.importRDF("file:///ontologies/resources/protege/automobile/volkswagen-inferred.owl", "Turtle", {shortenUrls: true, typesToLabels: true})

I'd like the query to return an instance and it's type (e.g. "Golf GTI S" and "Golf GTI") but am unable to formulate a query to do so. I've tried the following which returns no results:

MATCH (n:owlNamedIndividual)-[*..3]->(m:owlClass) WHERE n.rdfs__label = 'Golf GTI S' RETURN n, m LIMIT 25

Is there a way to get the type (rdf:type) of the instance?

Sample RDF, zipped:
volkswagen-inferred.owl.zip

jbarrasa commented 5 years ago

Hi masium, apologies for the embarrassingly late reply. I'm not giving this project the love it deserves :( Anyway, I've loaded your ontology and here's what I see. If you set the typesToLabels param to true, then your types will be represented as labels in Neo4j so the way to get all NamedIndividuals and their types would be:

MATCH (n:owl__NamedIndividual) RETURN n.rdfs__label as label, labels(n) as types

And this in your dataset returns:

image

I hope this helps.

JB.