在Python中使用Hermit推理程序进行本体检查的一致性 [英] Consistency checking using Hermit reasoner in Python for an Ontology

查看:392
本文介绍了在Python中使用Hermit推理程序进行本体检查的一致性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为python使用owlready2 api来加载一个本体,并使用 sync_reasoner()函数检查该本体的一致性.但是似乎并没有检查本体的一致性.尽管有错误,但什么也没有显示!知道如何使用owlready2或任何其他api在python中检查本体的一致性.

I am using owlready2 api for python to load an Ontology and check consistency for that ontology using the sync_reasoner() function. But it seems that it is not checking the consistency for the ontology. Although there is an error, it shows nothing! Any idea how can I check consistency of an ontology in python using owlready2 or any other api.

这是我的小代码:

from owlready2 import *
onto = get_ontology("test.owl")
sync_reasoner()

这是我得到的输出:

  • Owlready2 *正在运行HermiT ... java -Xmx2000M -cp C:\ Users \ 44999038 \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ site-packages \ owlready2 \ hermit; C:\ Users \ 44999038 \ AppData \ Local \ Programs \ Python \ Python36 -32 \ lib \ site-packages \ owlready2 \ hermit \ HermiT.jar org.semanticweb.HermiT.cli.CommandLine -c -O -D -I file:///C:/Users/44999038/AppData/Local/Temp /tmptmcc_a79
  • Owlready2 * HermiT花了0.48622655868530273秒
  • Owlready2 * Running HermiT... java -Xmx2000M -cp C:\Users\44999038\AppData\Local\Programs\Python\Python36-32\lib\site-packages\owlready2\hermit;C:\Users\44999038\AppData\Local\Programs\Python\Python36-32\lib\site-packages\owlready2\hermit\HermiT.jar org.semanticweb.HermiT.cli.CommandLine -c -O -D -I file:///C:/Users/44999038/AppData/Local/Temp/tmptmcc_a79
  • Owlready2 * HermiT took 0.48622655868530273 seconds

本体:

我修改的代码:

from owlready2 import *

onto = get_ontology("test.owl")
with onto:sync_reasoner()
onto.save()

我得到的输出猫头鹰文件:

Output owl file I have got:

推荐答案

您显示的输出只是OWLReady的输出,它从命令行调用HermiT推理机.因此,输出"为何相同的原因无关紧要.

The output you are showing is merely the output of OWLReady calling the HermiT reasoner from the commandline. Hence, the reason why the "output" is the same irrespective.

您需要的是分类后的推断结果.根据文档,您可以将推论直接引向文件,或从类中获取结果,如

What you need is the inference results after classification. According to the documentation you can direct the inferences to a file, or get the results from your classes as shown in this example.

不明显的是如何确定本体是否不一致.我能找到的最好的情况是,您需要搜索推理结果,如果可以找到与owl:Nothing等效的类,则您的本体是不一致的.

What is not obvious, is how to determine whether the ontology is inconsistent or not. The best I can find is that you need to search through the inference results and if you can find a class that is equivalent to owl:Nothing, your ontology is inconsistent.

这篇关于在Python中使用Hermit推理程序进行本体检查的一致性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆