Access to the iri range

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

Access to the iri range

Rickshow
Dear forum,
I am making a parser whose goal is to convert OWL text format to another format. I am making the script in Python with the owlready2 library.My problem arises when I try to access the data type inside the range IRI.

How can I access this object? I can't find a way to access the IRI

Example: <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#integer"/> 

in reference to "integer". I need to be able to access the IRI to be able to receive the integer string so I can convert it, the other option is to transform the IRI into a string and be able to access the #integer by hand but I can't.

Can anyone think of a solution and if not, how to do what I need to do?

Reply | Threaded
Open this post in threaded view
|

Re: Access to the iri range

Jiba
Administrator
Hello,

Owlready uses Python datatype for representing the datatype, but the corresponding IRI is stored in a dictionary, encoded as a store-ID.

You can obtain it as follows:

from owlready2 import *
import owlready2.base

storid = base._universal_datatype_2_abbrev[int]
iri = default_world._unabbreviate(storid)
# => iri = 'http://www.w3.org/2001/XMLSchema#integer'

The same will works for float, str, etc.

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

Re: Access to the iri range

Rickshow
Thanks for the response.

and How can I access to datatypes like long, decimal, double, byte and base64Binary? Or maybe these types of data are not contemplated? in my case it is necessary that they are these. I have seen that inside I have other types such as normstr, locstr, time and timedelta.
Reply | Threaded
Open this post in threaded view
|

Re: Access to the iri range

Jiba
Administrator
Hello,

You can also use the Property.range_iri attribute, that returns the range IRI, for instance ['http://www.w3.org/2001/XMLSchema#integer'] or ['http://www.w3.org/2001/XMLSchema#long'].

Note that it returns a list (because OWL allows a property to have several ranges, although it is rarely the case).

Jiba