# How to use inference with an imported ontology and rdf data

**URL:** <https://community.neo4j.com/t/how-to-use-inference-with-an-imported-ontology-and-rdf-data/18461>\
**Category:** Linked Data, RDF, Ontology\
**Created:** [May 11, 2020, 5:36pm UTC](https://community.neo4j.com/t/how-to-use-inference-with-an-imported-ontology-and-rdf-data/18461 "2020-05-11T17:36:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![boceckts](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/boceckts/32/11337_2.png) [@boceckts](https://community.neo4j.com/u/boceckts)\
**Post date:** [May 11, 2020, 5:36pm UTC](https://community.neo4j.com/t/how-to-use-inference-with-an-imported-ontology-and-rdf-data/18461/1 "2020-05-11T17:36:26Z")

</div>

Using the example of [Importing RFD Data](https://neo4j.com/docs/labs/nsmntx/current/import/#classes-as-nodes) (with [minionto](https://github.com/neo4j-labs/neosemantics/blob/4.0/docs/rdf/minionto.ttl) and [miniinstances](https://github.com/neo4j-labs/neosemantics/blob/4.0/docs/rdf/miniinstances.ttl)), 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](https://neo4j.com/docs/labs/nsmntx/current/inference/)) but it didn't give me any results.

```auto
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.

---

<div class="post-metadata">

**Author:** ![jesus\_barrasa](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/jesus_barrasa/32/27513_2.png) [@jesus\_barrasa](https://community.neo4j.com/u/jesus_barrasa)\
**Post date:** [May 14, 2020, 6:41pm UTC](https://community.neo4j.com/t/how-to-use-inference-with-an-imported-ontology-and-rdf-data/18461/2 "2020-05-14T18:41:47Z")

</div>

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:

```auto
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:

```auto
╒═════════════════════════════════╤════════════════════════╕
│"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.

---

<div class="post-metadata">

**Author:** ![boceckts](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/boceckts/32/11337_2.png) [@boceckts](https://community.neo4j.com/u/boceckts)\
**Post date:** [May 15, 2020, 8:11pm UTC](https://community.neo4j.com/t/how-to-use-inference-with-an-imported-ontology-and-rdf-data/18461/3 "2020-05-15T20:11:20Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![jesus\_barrasa](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/jesus_barrasa/32/27513_2.png) [@jesus\_barrasa](https://community.neo4j.com/u/jesus_barrasa)\
**Post date:** [May 16, 2020, 11:52am UTC](https://community.neo4j.com/t/how-to-use-inference-with-an-imported-ontology-and-rdf-data/18461/4 "2020-05-16T11:52:02Z")

</div>

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](https://neo4j.com/docs/labs/nsmntx/current/appendix_migration/) 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](https://neo4j.com/docs/labs/nsmntx/current/importing-ontologies/) for details):

1. Named class (category) declarations with both `rdfs:Class` and `owl:Class` .
2. Explicit class hierarchies defined with `rdf:subClassOf` statements.
3. Property definitions with `owl:ObjectProperty` , `owl:DatatypeProperty` and `rdfs:Property`
4. Explicit property hierarchies defined with `rdfs:subPropertyOf` statements.
5. Domain and range information for properties described as `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.
