对于OWL A级;获取所有属性A是它们的域 [英] For an OWL class A; Getting all properties that A is their domain

查看:132
本文介绍了对于OWL A级;获取所有属性A是它们的域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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.

让我们考虑以下本体:A1 subClassOf A; P domain A; P range B; 我用DL规则推理创建了一个本体模型,应该可以打开推理器.

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. 使用listDeclaredProperties():这是cls是我的OntClass的代码
  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());
}

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

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

问题1

为什么会这样(在域和范围中为Thing)?

此外,如果某些属性的域是交集,则将其忽略,即如果P domain A intersection B,而我将其称为A,则将不会检索P,这是典型的,因为A intersection B.

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.

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

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. 使用listStatements这只会检索明确说明的答案,即:
  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());
}

对于A1,这没有任何结果.这是A

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

问题3

为什么会发生这种情况(仅显示结果)?以及如何同时检索显式和推断结果?

Question 3

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

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

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.

推荐答案

这将检索正确的答案:其域为A的属性都为 明确的和推断的,但打印的域和范围设置为 事物.这是A和A1的输出:

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)?

OWL中的属性可以具有任意数量的域和范围.当属性P具有D作为域时,这意味着只要看到断言P(x,y),就可以推断 x是D的实例.这意味着在OWL中,猫头鹰:Thing是每个属性的域,因为每个断言的主题都必须是owl:Thing的实例.现在,请考虑Jena的

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返回属性的域中的一个. owl:Thing是属性的一个域,因此owl:Thing是合法的响应.如果要查看所有域,则需要使用

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().

但是,如何检索其域所在的属性 A还是subClassOfA以便检索A交集B?

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

您将需要使用推理器,即使使用推理器,将其表达为SPARQL查询也可能会更容易.然后,您将可以更加简洁地编写查询:

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
}

此查询将获取域为A或A的子类的所有属性.不过,为了推断A和B的交集是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?

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

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.).

这篇关于对于OWL A级;获取所有属性A是它们的域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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