Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
05-11-2020 10:36 AM
Using the example of Importing RFD Data (with minionto and miniinstances), I want to query all nodes that are a (direct or indirect) sublass of Person
which should result in the MarinaHyde
node.
I tried to use the following nodesLabelled
procedure (based on Inferencing/Reasoning) but it didn't give me any results.
CALL n10s.inference.nodesLabelled('Person', {
catNameProp: "rdfs__label",
catLabel: "rdfs__Class",
subCatRel: "rdfs__subClassOf"
})
YIELD node
RETURN node.uri as uri, labels(node) as categories;
Any help on how to make this work would be appreciated.
Solved! Go to Solution.
05-14-2020 11:41 AM
Hi @boceckts,
I think the example in the docs needs reviewing. Thanks for bringing it to my attention.
If you're fine with the IGNORE
option for the handleVocabUris
config param, then the easiest way to do it would be as follows:
call n10s.graphconfig.init({handleVocabUris:"IGNORE"});
call n10s.onto.import.fetch("https://github.com/neo4j-labs/neosemantics/raw/3.5/docs/rdf/minionto.ttl","Turtle");
call n10s.rdf.import.fetch("https://github.com/neo4j-labs/neosemantics/raw/3.5/docs/rdf/miniinstances.ttl","Turtle");
call n10s.inference.nodesLabelled('Person', {
catNameProp: "name",
catLabel: "Class",
subCatRel: "SCO"
})
YIELD node
RETURN node.uri as uri, labels(node) as categories
Which returns:
╒═════════════════════════════════╤════════════════════════╕
│"uri" │"categories" │
╞═════════════════════════════════╪════════════════════════╡
│"http://neo4j.org/ind#MarinaHyde"│["Resource","Columnist"]│
└─────────────────────────────────┴────────────────────────┘
Notice the n10s.onto.import.*
instead of n10s.rdf.import.*
for importing the ontology.
That said, let me think how to make it work for the case where you want to load the onto using n10s.rdf.import.*
. It may need a bit of re-thinking... ...watch this space.
Hope this helps anyway.
JB.
05-14-2020 11:41 AM
Hi @boceckts,
I think the example in the docs needs reviewing. Thanks for bringing it to my attention.
If you're fine with the IGNORE
option for the handleVocabUris
config param, then the easiest way to do it would be as follows:
call n10s.graphconfig.init({handleVocabUris:"IGNORE"});
call n10s.onto.import.fetch("https://github.com/neo4j-labs/neosemantics/raw/3.5/docs/rdf/minionto.ttl","Turtle");
call n10s.rdf.import.fetch("https://github.com/neo4j-labs/neosemantics/raw/3.5/docs/rdf/miniinstances.ttl","Turtle");
call n10s.inference.nodesLabelled('Person', {
catNameProp: "name",
catLabel: "Class",
subCatRel: "SCO"
})
YIELD node
RETURN node.uri as uri, labels(node) as categories
Which returns:
╒═════════════════════════════════╤════════════════════════╕
│"uri" │"categories" │
╞═════════════════════════════════╪════════════════════════╡
│"http://neo4j.org/ind#MarinaHyde"│["Resource","Columnist"]│
└─────────────────────────────────┴────────────────────────┘
Notice the n10s.onto.import.*
instead of n10s.rdf.import.*
for importing the ontology.
That said, let me think how to make it work for the case where you want to load the onto using n10s.rdf.import.*
. It may need a bit of re-thinking... ...watch this space.
Hope this helps anyway.
JB.
05-15-2020 01:11 PM
Hi @jesus.barrasa ,
thank you for your quick answer.
I already tried to play around with the graph config parameters by passing them to the import commands like this call n10s.rdf.import.fetch("...", "Turtle", {handleVocabUris: "IGNORE"})
. Unfortunately, it didn't work that way whereas your solutions works perfectly.
I'm also not sure about what's the difference between n10s.onto.import.*
vs n10s.rdf.import.*
but the way you described it works for me.
In the end, this is exactly the answer I was looking for!
Thanks again!
05-16-2020 04:52 AM
Great to hear.
Yeah, the handleVocabIUris
is no longer passed as a param of an individual import procedure but set as part of the Graph Configuration as you can see in the example I provided. This is one of the major changes in 4.0. I'd suggest you take a look at the migration guide in the manual if you're a 3.5 user or you are trying to reproduce examples from previous versions.
Also, to answer your question on the difference between rdf
and onto
variants of the import, I'd say that the n10s.onto.import.*
procedure imports only the following from the ontology (see manual for details):
rdfs:Class
and owl:Class
.rdf:subClassOf
statements.owl:ObjectProperty
, owl:DatatypeProperty
and rdfs:Property
rdfs:subPropertyOf
statements.rdfs:domain
and rdfs:range
statements.whereas the n10s.rdf.import.*
import includes every single triple. You will use one or the other depending on your needs but for integration with the inferencing capabilities in n10s, the n10s.onto.impoort.*
import makes things a lot easier.
Cheers,
JB.
All the sessions of the conference are now available online