unexpected property restriction generation

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

unexpected property restriction generation

gp
Hello,

When running the following code I get some unexpected property restriction:
from owlready2 import *

onto = get_ontology("http://test.org/onto.owl")

with onto:
    class Drug(Thing):
        pass
    Drug.iri = "http://test.org/onto.owl#SomeDrugIri"
    class Ingredient(Thing):
        pass
    Ingredient.iri = "http://test.org/onto.owl#SomeIngredientIRI"
    class has_for_ingredient(ObjectProperty):
        domain    = [Drug]
        range     = [Ingredient]
    has_for_ingredient.iri = "http://test.org/onto.owl#Somehas_for_ingredientIri"


with onto:
    class has_for_ingredient(Drug >> Ingredient):
        pass

with onto:
    class subDrug(Drug):
        pass
    subDrug.iri = 'http://test.org/onto.owl#yoplaboum'
    drugIndividual = Drug(name='magicDrug')
    ingredientIndividual = Ingredient(name='guarana')

    has_for_ingredient[drugIndividual].append(Ingredient)
    has_for_ingredient[drugIndividual].append(ingredientIndividual)

    has_for_ingredient[subDrug].append(ingredientIndividual)

print(ingredientIndividual.is_a)
onto.save(r'c:\temp\drug.owl')

the output of the print function is: [onto.SomeIngredientIRI, Inverse(onto.has_for_ingredient).some(onto.yoplaboum)], note the Inverse property restrictions, which is then serialized accordingly in the export file.

I did not expect this restriction from the code, did I miss something here?

Cheers,
Guillaume
Reply | Threaded
Open this post in threaded view
|

Re: unexpected property restriction generation

Jiba
Administrator
Hello,

I think the restriction is added by the following line:

    has_for_ingredient[subDrug].append(ingredientIndividual)

This line is a "shortcut" of Owlready : it defines a "relation" between a class (SubDrug) and an individual (ingredientIndividual). Such relations do not exist in OWL (OWL only allows relations between 2 individuals). Thus, Owlready automatically "translates" the relation in restrictions. 2 restrictions are created, one for SubDrug and one for ingredientIndividual.

I still need to document better those shortcuts...

Best regards,
Jiba
gp
Reply | Threaded
Open this post in threaded view
|

Re: unexpected property restriction generation

gp
Hi,

Ok this makes sense.
As of the OWL only allows relations between 2 individuals, is it not only OWL (2) DL which has this restriction?

Cheers,
Guillaume
Reply | Threaded
Open this post in threaded view
|

Re: unexpected property restriction generation

Jiba
Administrator
Hello,

I'm not sur on that point -- I think that relation are only for individuals, for example in Protégé you cannot set a relation on a class (you can only define subclasses and restrictions). However, OWL allows "punning", in which an entity can be both a class and an entity.  But it is not supported by Owlready and reasoning tools treat such an entity as two distinct entities, so punning is usually not very useful.

Best regards,
Jean-Baptiste Lamy
MCF HDR, Laboratoire LIMICS, Université Paris 13
gp
Reply | Threaded
Open this post in threaded view
|

Re: unexpected property restriction generation

gp
Hi,

I protege think has been owl DL only since version 4 or so (5 maybe ?), which would explain this. Since the tool is the de facto standard it is probably best to have owlready be on the same line whatever the theory behind it.

As of punning, I agree I also fail to see a real benefice when it comes to modeling. Some fairly popular ontologies like OBI do use it explicitly though, so we may both have missed something here...

Cheers,
Guillaume