KeyError: 'datatypeIRI' in owlready library

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

KeyError: 'datatypeIRI' in owlready library

murattkilinc

what could be the reason I am getting key error in the following python code?

CODE:

from owlready import *

onto = get_ontology("file://C:/Users/BAUM-PC/Desktop/izmir/deneme.owl")
onto.load()

graph = default_world.as_rdflib_graph()
r = list(graph.query("""
    PREFIX uni:<http://muratkilinc.com/~ontologies/izmir.owl#>
        PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
        PREFIX un: <http://www.w3.org/2007/ont/unit#>
        PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
        SELECT ?adi ?soyadi ?yas
        WHERE
        {
                ?turistler uni:yas ?yas.
                ?turistler uni:adi ?adi.
                ?turistler uni:soyadi ?soyadi.
                FILTER(?yas > 35 && ?yas < 45).
               
        }"""))

results = default_world.as_rdflib_graph().query_owlready(r)
results = list(results)
print(results)

ERROR:

KeyError: 'datatypeIRI
Reply | Threaded
Open this post in threaded view
|

Re: KeyError: 'datatypeIRI' in owlready library

Jiba
Administrator
Hi,

I've managed to make your example running, using the code below.

If the problem persists, it is probably related to the content of your ontology. In this case, could you send it to me please?

Jiba


from owlready2 import *
import sys, time

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

with get_ontology("http://muratkilinc.com/~ontologies/izmir.owl#"):
  class yas(DataProperty): pass
  class adi(DataProperty): pass
  class soyadi(ObjectProperty): pass

with onto:
  class C(Thing): pass
  c0 = C()
  c1 = C(yas = [42], adi = [40], soyadi = [c0])
 
graph = default_world.as_rdflib_graph()
r = list(graph.query_owlready("""
    PREFIX uni:<http://muratkilinc.com/~ontologies/izmir.owl#>
        PREFIX rdfs:<http://www.w3.org/2000/01/rdf-schema#>
        PREFIX un: <http://www.w3.org/2007/ont/unit#>
        PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
        SELECT ?adi ?soyadi ?yas
        WHERE
        {
                ?turistler uni:yas ?yas.
                ?turistler uni:adi ?adi.
                ?turistler uni:soyadi ?soyadi.
                FILTER(?yas > 35 && ?yas < 45).
               
        }
"""))
print(r)