I have a simple ontology with different classes, which courses
and lessons
are classes. I'm trying to run a SWRL rule that associates a property belongsTo
to individuals of the lessons
. I'm using OWLReady2 and Python
with onto:
#courses
class course_id (onto.courses >> int): pass
class course_title (onto.courses >> str): pass
#lessons
class lesson_id (onto.lessons >> int): pass
class lesson_title (onto.lessons >> str): pass
class course_id (onto.lessons >> int): pass
class belongTo(onto.lessons >> onto.courses): pass
rule = Imp()
rule.set_as_rule("""lessons(?l), courses(?c), course_id(?c, ?cid), course_id(?l, ?cid) -> belongTo(?l, ?c) """)
sync_reasoner_pellet(infer_property_values = True, infer_data_property_values = True)
The idea is that if the course_id
are similar, the lesson should belong to the course. But my code does not seem to be working. I'm getting these inferences:
* Owlready * Adding relation lmsontology.Introduction belongTo lmsontology.Introduction
* Owlready * Adding relation lmsontology.Databases belongTo lmsontology.Databases