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

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.

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

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.

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.

This is what I mean:

// 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

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", it is strange :confused:

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

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

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

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 ;
1 Like

Hello @jesus_barrasa it works like a magic :smiley:
Thanks.

1 Like

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