How to get the OWL data type assigned to a restriction?

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

How to get the OWL data type assigned to a restriction?

Akash
Hello,

I have a restriction "hasIdentifier some xsd:string" placed on Class A.

How can I retrieve the OWL data type "xsd:string" from this restriction after loading the ontology using owlready?

Currently, I am able to do "ontology.ClassA.is_a[1].value" which gives me <class 'str'> in python. Just wondering if there is a way to get the original data type assigned in the owl file.

Thanks,
Akash
Reply | Threaded
Open this post in threaded view
|

Re: How to get the OWL data type assigned to a restriction?

Jiba
Administrator
Hi,

Owlready uses plain Python types to represent basic datatype, so str is the datatype.

If you want the IRI of the datatype, it is more complex... Owlready maintain a dictionary mapping Python types to IRI, but the IRI are abbreviated as integer. Thus you need to unabbreviate them. Here is an exemple :

>>> default_world._unabbreviate(owlready2.base._universal_datatype_2_abbrev[str])
'http://www.w3.org/2001/XMLSchema#string'

Jiba
Reply | Threaded
Open this post in threaded view
|

Re: How to get the OWL data type assigned to a restriction?

Akash
Thanks for the help! This is exactly what I was looking for.