我有一个包含不同类的简单本体,其中courses
和lessons
是类。我正在尝试运行一个SWRL规则,该规则将属性belongsTo
关联到lessons
的个人。我正在使用OWLReady2和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)
这个想法是,如果course_id
是相似的,那么课程应该属于课程。但我的代码似乎不起作用。我得到了这些推论:
* Owlready * Adding relation lmsontology.Introduction belongTo lmsontology.Introduction
* Owlready * Adding relation lmsontology.Databases belongTo lmsontology.Databases
在您的示例中,我检测到以下问题:
courses
和lessons
的类李>course_id
定义了两次,使第一个过时hasId
李>一般来说,为了调试规则,我建议从一个琐碎的规则或工作示例逐步构建它,并在每个步骤中检查结果是否符合预期
相关问题 更多 >
编程相关推荐