# How to import two ontologies with two different Labels for the owl:Class?

**URL:** <https://community.neo4j.com/t/how-to-import-two-ontologies-with-two-different-labels-for-the-owl-class/54097>\
**Category:** Linked Data, RDF, Ontology\
**Created:** [March 29, 2022, 3:39pm UTC](https://community.neo4j.com/t/how-to-import-two-ontologies-with-two-different-labels-for-the-owl-class/54097 "2022-03-29T15:39:05Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![siham.elfedali](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/siham.elfedali/32/3932_2.png) [@siham.elfedali](https://community.neo4j.com/u/siham.elfedali)\
**Post date:** [March 29, 2022, 3:39pm UTC](https://community.neo4j.com/t/how-to-import-two-ontologies-with-two-different-labels-for-the-owl-class/54097/1 "2022-03-29T15:39:05Z")

</div>

Hello, I am working on Neo4j v4.3 (Community) and with neosematics (n10s) v4.3.0, I have two ontologies to import into the same Graph. the problem is I can't import the two ontologies with two different Labels for the owl: Class.  
Does someone have any suggestions?  
Thanks for your help.

---

<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:** [March 29, 2022, 6:14pm UTC](https://community.neo4j.com/t/how-to-import-two-ontologies-with-two-different-labels-for-the-owl-class/54097/2 "2022-03-29T18:14:10Z")

</div>

You're right, once you set the label you want to use for owl:Class instances, it will be applied to all the ontologies you import. What's the rationale behind wanting to change it on a per ontology basis?  
Items should be uniquely identified by URI so no problem to track provenance.

If you want to add additional tagging you can maybe combine `n10s.rdf.stream.*` with custom cypher?

JB

---

<div class="post-metadata">

**Author:** ![siham.elfedali](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/siham.elfedali/32/3932_2.png) [@siham.elfedali](https://community.neo4j.com/u/siham.elfedali)\
**Post date:** [March 30, 2022, 7:53am UTC](https://community.neo4j.com/t/how-to-import-two-ontologies-with-two-different-labels-for-the-owl-class/54097/3 "2022-03-30T07:53:25Z")

</div>

Actually for my use case I want to visualize those ontologies in the front end of my application, so I need to keep the owl:Class of every ontology separate for example for the first ontology I want the owl:Class with the label **IfcClass** and for the second ontology I want to set the owl:Class with the label **RSMClass**. Concerning the use of n10s.rdf.stream.\* it's not the best choice for me because I want to write the both ontologies in my DB.

---

<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:** [March 30, 2022, 8:12am UTC](https://community.neo4j.com/t/how-to-import-two-ontologies-with-two-different-labels-for-the-owl-class/54097/4 "2022-03-30T08:12:56Z")

</div>

I think that's exactly what you would achieve with `rdf.stream`.  
You first import the ontology in the standard way via `n10s.onto.import.*` and then do a second pass on the same ontology with `n10s.rdf.stream.*` just adding the additional label on the classes.  
At the end all owl classes would be both a Class **and** an LFCClass, an RSMClass, etc...  
You can have multiple labels applied to nodes in Neo4j.

JB.

---

<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:** [March 30, 2022, 8:17am UTC](https://community.neo4j.com/t/how-to-import-two-ontologies-with-two-different-labels-for-the-owl-class/54097/5 "2022-03-30T08:17:22Z")

</div>

This is what I mean:

```auto
// Import the onto
call n10s.onto.import.fetch("https://url_of_your_ontology","Turtle");

// Add the extra labels
call n10s.rdf.stream.fetch("https://url_of_your_ontology","Turtle") yield subject, predicate, object 
where predicate = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" and 
        object = "http://www.w3.org/2002/07/owl#Class"
match (r:Resource { uri: subject }) SET r:LFCClass

```

---

<div class="post-metadata">

**Author:** ![siham.elfedali](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/siham.elfedali/32/3932_2.png) [@siham.elfedali](https://community.neo4j.com/u/siham.elfedali)\
**Post date:** [March 31, 2022, 9:28am UTC](https://community.neo4j.com/t/how-to-import-two-ontologies-with-two-different-labels-for-the-owl-class/54097/6 "2022-03-31T09:28:13Z")

</div>

Hello @jesus_barrasa actually I tried your suggestion, but I don't know the reason my graph is not updated, and I can't see that the labels are updated, even after executing the procedures I received just _(no changes, no records)_.  
By the way, when I run the procedure **CALL n10s.rdf.stream.fetch("https://url\_of\_your\_ontology","Turtle")**; I can't find any object with URL **"[http://www.w3.org/2002/07/owl#Class](http://www.w3.org/2002/07/owl#Class)"**, it is strange 😕

---

<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:** [March 31, 2022, 10:43am UTC](https://community.neo4j.com/t/how-to-import-two-ontologies-with-two-different-labels-for-the-owl-class/54097/7 "2022-03-31T10:43:13Z")

</div>

can you share the onto (or a part of it) that you're trying to load so we can try to reproduce?

---

<div class="post-metadata">

**Author:** ![siham.elfedali](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/siham.elfedali/32/3932_2.png) [@siham.elfedali](https://community.neo4j.com/u/siham.elfedali)\
**Post date:** [March 31, 2022, 12:06pm UTC](https://community.neo4j.com/t/how-to-import-two-ontologies-with-two-different-labels-for-the-owl-class/54097/8 "2022-03-31T12:06:44Z")

</div>

Hello, this is the link of the ontology that I am using [https://standards.buildingsmart.org/IFC/DEV/IFC4\_3/RC1/OWL/IFC4x3\_RC1.ttl](https://standards.buildingsmart.org/IFC/DEV/IFC4_3/RC1/OWL/IFC4x3_RC1.ttl)

---

<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:** [March 31, 2022, 7:32pm UTC](https://community.neo4j.com/t/how-to-import-two-ontologies-with-two-different-labels-for-the-owl-class/54097/9 "2022-03-31T19:32:09Z")

</div>

This script seems to do the job.  
Check it out and let us know.  
I use the same principle to load the owl:NamedIndividual (there's a bunch of them in your onto and they're not loaded by default by `n10s.onto.import.*`

Cheers,

JB

```auto
CREATE CONSTRAINT n10s_unique_uri ON (r:Resource) ASSERT r.uri IS UNIQUE ;

call n10s.graphconfig.init() ;

call n10s.nsprefixes.addFromText('

@prefix ifc: <http://standards.buildingsmart.org/IFC/DEV/IFC4_3/RC1/OWL#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix dce: <http://purl.org/dc/elements/1.1/> .
@prefix vann: <http://purl.org/vocab/vann/> .
@prefix list: <https://w3id.org/list#> .
@prefix expr: <https://w3id.org/express#> .
@prefix cc: <http://creativecommons.org/ns#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

') ;
// first pass, load the onto. Note that there are irregular uris, but we accept them with verifyUriSyntax: false 
call n10s.onto.import.fetch("https://standards.buildingsmart.org/IFC/DEV/IFC4_3/RC1/OWL/IFC4x3_RC1.ttl","Turtle", { verifyUriSyntax: false }) ;

// we want named instances to link to the classes imported from the onto, so we change the handleRDFTypes mode.
call n10s.graphconfig.set({handleRDFTypes: "NODES",force:true}) ;

// second pass to load the owl:NamedIndividual 
call n10s.rdf.stream.fetch("https://standards.buildingsmart.org/IFC/DEV/IFC4_3/RC1/OWL/IFC4x3_RC1.ttl","Turtle", { verifyUriSyntax: false , limit :100000}) yield subject, predicate, object
where predicate = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" and
        object = "http://www.w3.org/2002/07/owl#NamedIndividual"
with collect(subject) as namedIndividuals
call n10s.rdf.stream.fetch("https://standards.buildingsmart.org/IFC/DEV/IFC4_3/RC1/OWL/IFC4x3_RC1.ttl","Turtle", { verifyUriSyntax: false , limit :100000}) yield subject, predicate, object, isLiteral, literalType, literalLang, subjectSPO
where subject in namedIndividuals and not ( predicate = "http://www.w3.org/1999/02/22-rdf-syntax-ns#type" and object = "http://www.w3.org/2002/07/owl#NamedIndividual" )
with n10s.rdf.collect(subject, predicate, object, isLiteral, literalType, literalLang, subjectSPO) as individualsAsRDF
call n10s.rdf.import.inline(individualsAsRDF, "N-Triples",{verifyUriSyntax: false}) yield terminationStatus,triplesLoaded, triplesParsed, namespaces, extraInfo, callParams
return terminationStatus,triplesLoaded, triplesParsed, namespaces, extraInfo, callParams ;

// add label to owl:NamedIndividual
match (ni:Resource)-[:rdf__type]->() 
with distinct ni
set ni:owl__NamedIndividual ;

```

---

<div class="post-metadata">

**Author:** ![siham.elfedali](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/siham.elfedali/32/3932_2.png) [@siham.elfedali](https://community.neo4j.com/u/siham.elfedali)\
**Post date:** [April 1, 2022, 1:01pm UTC](https://community.neo4j.com/t/how-to-import-two-ontologies-with-two-different-labels-for-the-owl-class/54097/10 "2022-04-01T13:01:36Z")

</div>

Hello @jesus_barrasa it works like a magic 😃  
Thanks.

---

<div class="post-metadata">

**Author:** ![vaddi.b](https://sea1.discourse-cdn.com/flex021/user_avatar/community.neo4j.com/vaddi.b/32/32675_2.png) [@vaddi.b](https://community.neo4j.com/u/vaddi.b)\
**Post date:** [September 12, 2024, 1:11pm UTC](https://community.neo4j.com/t/how-to-import-two-ontologies-with-two-different-labels-for-the-owl-class/54097/11 "2024-09-12T13:11:42Z")

</div>

Hello @jesus_barrasa

i an new to this neosematics and i have a doubt and how can i get the class names as label names while fetching ontology. I am getting some random names instead.

this is my file

[https://cdn.aidtaas.com/\_91728b69-5a3d-4f19-a35b-a90adf99fc20/bottle/limka/soda/af43bab7-1362-4aff-9f70-de739f2f7e22\_$$\_V1\_People\_Example.owl](https://cdn.aidtaas.com/_91728b69-5a3d-4f19-a35b-a90adf99fc20/bottle/limka/soda/af43bab7-1362-4aff-9f70-de739f2f7e22_$$_V1_People_Example.owl)
