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

Posted by Jiba on
URL: http://owlready.306.s1.nabble.com/Unable-to-provide-SWRL-rules-to-my-ontology-and-its-concept-tp2817p2822.html

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)