Unable to provide SWRL rules to my. ontology and its concept.

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

Unable to provide SWRL rules to my. ontology and its concept.

Richu
Hi there,

I've been trying to add the SWRL rules to my existing ontology which has the instances. There are no errors but I'm unable to add new rules. I've attached the image of the code.


Thank you =D
Reply | Threaded
Open this post in threaded view
|

Re: Unable to provide SWRL rules to my. ontology and its concept.

Richu
And please ignore the rules, I'm just testing it.
Reply | Threaded
Open this post in threaded view
|

Re: Unable to provide SWRL rules to my. ontology and its concept.

Jiba
Administrator
Hello,

I tested the following code, inspired by your code, and it works well. Are you sure the instances are created, as well as the properties ? Notice that you cannot create the property AFTER setting its value in the instance.


from owlready2 import *

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

with onto:
  class Person(Thing): pass
  class Project(Thing): pass
  class E(Thing): pass
     
  class hasProject(Person >> Project): pass
  class hasPerson(Project >> Person): pass

  kilian  = Person("Kilian")
  project = Project(hasPerson = [kilian])
 
  rule = Imp()
  rule.set_as_rule("""hasPerson(?a, ?b) -> hasProject(?b, ?a)""")
                   
  default_world.graph.dump()
 
  sync_reasoner_pellet(infer_property_values = True, infer_data_property_values = True)

print(project.hasPerson)
print(kilian.hasProject)
print(project.is_a, kilian.is_a)