Different base_iri for my onttology when using .load twice

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Different base_iri for my onttology when using .load twice

IWilliams
I have the folowing:
onto = get_ontology('file://' + settings.ONTOLOGY_DIR + "UseCaseAssignmentASE2020.owl").load(reload = True,
                                                                                                 reload_if_newer = True)
and the base_iri is file://pathtofilesystem\UseCaseAssignmentASE2020.owl#
However, when I run the same line else where in my code:
onto = get_ontology('file://' + settings.ONTOLOGY_DIR + "UseCaseAssignmentASE2020.owl").load(reload = True,
                                                                                                 reload_if_newer = True)

the base_iri is http://www.semanticweb.org/imano/ontologies/2020/1/untitled-ontology-13#

I created the ontology in Protege and I am using Owlready2 to asset individual facts in the ontology.

Why is the second load using the http://www.semanticweb.org/imano/ontologies/2020/1/untitled-ontology-13# instead of file://pathtofilesystem\UseCaseAssignmentASE2020.owl# for the base_iri?

Reply | Threaded
Open this post in threaded view
|

Re: Different base_iri for my onttology when using .load twice

Jiba
Administrator
Hi,

If you load your ontology from a file, its base_iri is normalized reinitialized with the value contained in that file. Is it "file://..." or "http://www.semanticweb.org/imano/ontologies/2020/1/untitled-ontology-13#" ?

I advice to not use file://... as IRI, but IRI starting with http:// or https://, since some tools do not accept file://... IRI.

Notice that you can load the ontology by giving a filename (without file://) to .load().

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: Different base_iri for my onttology when using .load twice

IWilliams
The use case that I am using owlready2 in is somewhat tricky.
Scenario:
I have the owl file and there are many users in the system. Let's say the owl file has an ontology (Tbox) about a house. Each user may want to model their own house. So, when the user wants to model their house,
1. the system get and load the ontology.
2. using with onto, the system would populate the (Abox) with information about the house.
3. the system saves loaded ontology to another owl file.
As you can see, every user that wants to model a house will get and load the same ontology from file. It is just the saved owl file that is different.
I read through owlready2's code and I understand how I can change the default parameter values of the load method, such as reload=True and reload_if_newer=True and how they affect the what happens to a loaded ontology from file.
I decided to change the base_iri of the ontology, so that the system can get it from the web instead of local file system (works well). However, I have not tested it with many use session to my Django application.

Reply | Threaded
Open this post in threaded view
|

Re: Different base_iri for my onttology when using .load twice

Jiba
Administrator
In such a scenario, I advice to either:

1) use a different World for each user, allowing to load the same ontology and to modify it in different way with no interaction between the users, or

2) to split the ontology in several parts: one fixed part with the common entities shared by all users, and never modified (e.g. your House class), AND one ontology per user, which import the previous one and create the user-specific entities (e.g. their own house).

Jiba