首页 \ 问答 \ 对于OWL A级;(For an OWL class A; Getting all properties that A is their domain)

对于OWL A级;(For an OWL class A; Getting all properties that A is their domain)

首先我知道这个话题可能会重复,但实际上我还有其他问题。 我正在使用Jena来操纵OWL本体。 给定A类,我想找到A是其域的所有属性,无论这是显式的还是推断的。

让我们考虑以下本体: A1 subClassOf A; P domain A; P range B; A1 subClassOf A; P domain A; P range B; 我创建了一个带有DL规则推理的本体moel,这应该会打开推理器。

ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM_RULE_INF)

一个解决方法介绍了执行此任务的两种方法:

  1. 使用listDeclaredProperties() :这是cls是我的OntClass的代码

ExtendedIterator<OntProperty> exItr;        
exItr = cls.listDeclaredProperties(false);      
while (exItr.hasNext()) {
  OntProperty prop = exItr.next();
  System.out.println("Object Property Name: "+ prop.getLocalName());
  System.out.println("Domain: "+ prop.getDomain());
  System.out.println("Range: "+ prop.getRange());
}

这将检索正确答案:其域为A属性是显式和推断的,但打印的域和范围设置为Thing。 这是AA1的输出:

Object Property Name: P
Domain: http://www.w3.org/2002/07/owl#Thing
Range: http://www.w3.org/2002/07/owl#Thing

问题1

为什么会发生这种情况(域和范围内的Thing )?

此外,如果某个属性的域是交叉点,则忽略它,即如果P domain A intersection B ,并且我将其称为A ,则不会检索P ,这是典型的,因为A intersection BsubClassOf A

问题2

但是,如何检索其域为AsubClassOf A的属性以便检索A intersection B

  1. 使用listStatements这只检索明确说明的答案,即:

StmtIterator it = model.listStatements(null, RDFS.domain, cls);
while (it.hasNext()) {
  Statement stmt = it.next();
  System.out.println("Object Property Name: "+ prop.getLocalName());
  System.out.println("Domain: "+ stmt.getSubject());
}

这对于A1没有任何结果。 这是A的结果

Object Property Name: P
Domain: http://www.w3.org/2002/07/owl#A
Range: http://www.w3.org/2002/07/owl#B

问题3

为什么会发生这种情况(只有明确的结果)? 以及如何检索显式和推断结果?

此外,这种方式还检索AA intersection B是其域的属性(问题2的答案),为什么会发生这种情况? 我有点迷失了。


First I know this topic maybe repeated, but actually I have further questions. I'm using Jena to manipulate OWL ontology. Given a class A, I want to find all properties that A is their domain whether this is explicit or inferred.

Let's consider the following ontology: A1 subClassOf A; P domain A; P range B; I create an ontology moel with DL rule inference, this is supposed to turn reasoner on.

ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM_RULE_INF)

A work around introduced two methods for doing this task:

  1. Using listDeclaredProperties(): this is the code where cls is my OntClass

ExtendedIterator<OntProperty> exItr;        
exItr = cls.listDeclaredProperties(false);      
while (exItr.hasNext()) {
  OntProperty prop = exItr.next();
  System.out.println("Object Property Name: "+ prop.getLocalName());
  System.out.println("Domain: "+ prop.getDomain());
  System.out.println("Range: "+ prop.getRange());
}

This retrieves correct answer: properties that its domain is A both explicit and inferred, but the printed domains and ranges are set to Thing. This is the output for both A and A1 :

Object Property Name: P
Domain: http://www.w3.org/2002/07/owl#Thing
Range: http://www.w3.org/2002/07/owl#Thing

Question 1

Why is this happening (Thing in domain and range)?

Besides, if the domain of some property is intersection, it's ignored i.e. if P domain A intersection B, and I call this for A, P will not be retrieved, this is typical because A intersection B is a subClassOf A.

Question 2

However, how can I retrieve the properties which their domain is either A or a subClassOf A in order to retrieve A intersection B?

  1. Using listStatements This only retrieves the explicitly stated answer i.e:

StmtIterator it = model.listStatements(null, RDFS.domain, cls);
while (it.hasNext()) {
  Statement stmt = it.next();
  System.out.println("Object Property Name: "+ prop.getLocalName());
  System.out.println("Domain: "+ stmt.getSubject());
}

This gives no results nothing for A1. and this is the result for A

Object Property Name: P
Domain: http://www.w3.org/2002/07/owl#A
Range: http://www.w3.org/2002/07/owl#B

Question 3

Why is this happening (only explicit results)? and how to retrieve both explicit and inferred results?

Besides, this way also retrieves properties that A or A intersection B is its domain (an answer for question.2), why is this happening? I'm getting a bit lost.


原文:https://stackoverflow.com/questions/27924868
更新时间:2020-03-23 22:25

最满意答案

这将检索正确答案:其域为A的属性是显式和推断的,但打印的域和范围设置为Thing。 这是A和A1的输出:

Object Property Name: P
Domain: http://www.w3.org/2002/07/owl#Thing
Range: http://www.w3.org/2002/07/owl#Thing

为什么会发生这种情况(域和范围内的事情)?

OWL中的属性可以包含任意数量的域和范围。 当属性P具有D作为域时,这意味着每当您看到断言P(x,y)时,您可以推断 x是D的实例。这意味着在OWL中,owl:Thing是每个域的域属性,因为每个断言的主题必须是owl的实例:Thing。 现在,考虑一下Jena的OntProperty#getDomain()的文档(强调添加):

回答表示此属性的域类的资源。 如果存在多个这样的资源,则进行任意选择。

耶拿返回该物业的其中一个域名。 猫头鹰:东西是财产的一个领域,所以猫头鹰:东西是一个有效的回应。 如果要查看所有域,则需要使用OntProperty#listDomain()

但是,如何检索其域为A或subClassOf A的属性以便检索A交叉点B?

您需要使用推理器,即使使用推理器,也可以更容易将其表达为SPARQL查询。 然后你就可以更简洁地写出查询了:

select ?property where {
  ?property rdfs:domain/rdfs:subClassOf* ex:A
}

此查询将获取其域为A或A的子类的所有属性。但是,您仍然需要推理器,以便推断A和B的交集是A的子类。

为什么会发生这种情况(只有明确的结果)? 以及如何检索显式和推断结果?

如果您使用推理器,则只会推断出结果。 Jena的reasoners在逻辑上也不完整 ,这意味着有一些结果是Jena的reasoners不会产生的合法的OWL结果。 您可能遇到过其中一种情况,或者代码中可能仍然存在问题。 但是,在这些情况下,您可能应该生成一个完整的工作示例并使用完整的代码提出问题,以及我们可以用来重现问题的完整本体。 您还应该尝试不同的reasoners(Jena提供的其他reasoners以及Pellet,HermiT等的reasoners)。


This retrieves correct answer: properties that its domain is A both explicit and inferred, but the printed domains and ranges are set to Thing. This is the output for both A and A1 :

Object Property Name: P
Domain: http://www.w3.org/2002/07/owl#Thing
Range: http://www.w3.org/2002/07/owl#Thing

Why is this happening (Thing in domain and range)?

Properties in OWL can have any number of domains and ranges. When property P has D as a domain, it means that any time you see an assertion P(x,y), you can infer that x is an instance of D. That means that in OWL, owl:Thing is a domain of every property, since the subject of every assertion must be an instance of owl:Thing. Now, consider the documentation of Jena's OntProperty#getDomain() (emphasis added):

Answer a resource that represents the domain class of this property. If there is more than one such resource, an arbitrary selection is made.

Jena returns one of the domains of the property. owl:Thing is a domain of the property, so owl:Thing is a legimate response. If you want to view all the domains, then you need to use OntProperty#listDomain().

However, how can I retrieve the properties which their domain is either A or a subClassOf A in order to retrieve A intersection B?

You'd need to use a reasoner, and even with a reasoner, it might be easier to express this as a SPARQL query. Then you'd be able to write much more concisely the query:

select ?property where {
  ?property rdfs:domain/rdfs:subClassOf* ex:A
}

This query will get all properties whose domain is A or a subclass of A. You'll still need the reasoner, though, in order to infer that the intersection of A and B is a subclass of A.

Why is this happening (only explicit results)? and how to retrieve both explicit and inferred results?

There will only be inferred results if you use a reasoner. Jena's reasoners aren't logically complete, either, which means that there are some results that are legal OWL results that Jena's reasoners won't produce. You might have run into one of those cases, or there might still be issues in the code. In those cases, though, you probably should produce a complete working example and ask a question with complete code, and a complete ontology that we can use to reproduce the problem. You should also experiment with different reasoners (both the other reasoners provided by Jena as well as reasoners such as Pellet, HermiT, &c.).

2015-01-13

相关文章

更多

最新问答

更多
  • 如何避免MDIParent表单调整大小(How do I avoid MDIParent form from resizing)
  • Angular自定义指令调用另一个自定义指令(Angular custom directive calling another custom directive)
  • 如何通过参数将文本解析并附加到SQL Server 2005中的存储过程(How to Parse and Append text to a stored procedure in SQL Server 2005 via a parameter)
  • OpenCV中心Homography(OpenCV Center Homography)
  • 如何在linux shell脚本中计算日期-N?(How to calculate date -N in linux shell scripting?)
  • 如何使用Devise创建用户配置文件?(How Do I Create a User Profile With Devise?)
  • 清理模式以管理树上的多步异步过程(Clean pattern to manage multi-step async processes on a tree)
  • 场景的角色(Role of the Scene)
  • 组件中的Angular 2组件[重复](Angular 2 Component In Component [duplicate])
  • jsPlumb draggable element javascript函数(jsPlumb draggable element javascript function)
  • MVC4:ViewModel(带有radiobuttonlist)在HttpPost之后为空(MVC4: ViewModel (with radiobuttonlist) is empty after HttpPost)
  • 如何在同一帐户上设置“Dev repo”(在prod和团队之间)(How to set up a “Dev repo” (between the prod and the team) on the same account)
  • 如何在tcl中将eth0配置为发送方udp端口(how to configure eth0 as a sender udp port in tcl)
  • 如何使用预定义文本替换来自数据库的部分结果(How do I replace part of result coming from Database with predefined text)
  • Selenium Java注入了新的Javascript函数(Selenium Java inject new Javascript function)
  • 使用.on的多个下拉菜单选择文本仅适用于第一个下拉列表(Multiple Dropdowns Menu Selection text using .on works only on first dropdown)
  • 快速将黄土曲线添加到大型数据集图中的方法(Quick way to add loess curve to large data set graph)
  • FilteringSelect in mvc(FilteringSelect in mvc)
  • 在Delphi XE2中开发Mac或iOS应用程序需要哪些硬件/软件?(What hardware/software is necessary to develop Mac or iOS apps in Delphi XE2?)
  • 在原型的构造函数中初始化属性时获取“未定义”(Getting 'undefined' when a property is initialized in the constructor of a prototype)
  • 通过越狱加载的应用程序的Documents文件夹位置(Location of Documents folder for an app loaded via jailbreak)
  • 在OpenGL中使用可编程和固定管道功能(Using both programmable and fixed pipeline functionality in OpenGL)
  • 将任何用户输入重定向到单独的底层程序(redirect any user input to a separate underlying program)
  • 编辑文本不能正常工作android(Edit texts not working properly android)
  • “user_denied”Facebook应用页面上的Facebook用户区域设置(Facebook user locale on “user_denied” facebook app page)
  • 在大图像中找到小的部分透明图像的坐标(find coordinates of small partially-transparent image within a large image)
  • 我如何在cakephp 3.1中获得完整的相对路径?(How i can get full relative path of image in cakephp 3.1?)
  • 如何保存拖动标记的新本地化?(How to save new localization of dragged marker?)
  • MySQL UPDATE vs INSERT和DELETE(MySQL UPDATE vs INSERT and DELETE)
  • 在执行查询之前,在SQLAlchemy模型中将datetime转换为unix时间戳?(Convert datetime to unix timestamp in SQLAlchemy model before executing query?)