对象属性的一类 [英] object property for a class

查看:117
本文介绍了对象属性的一类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能确定在耶拿类对象的属性。我能得到的所有对象的属性,但我想要得到的对象属性特定类。

code为让所有的objectProperties:

  ExtendedIterator对象= m.listObjectProperties();  而(objects.hasNext())
       {
            物业essaProperty =(物业)objects.next();
            的System.out.println(Propiedad:+ essaProperty.getLocalName());       }

另外,我怎么能得到相关的类的对象属性,我的意思是,知道怎样才能得到对象属性 - >我怎么能得到B

 
                             (A ----------> B)

感谢


解决方案

您可能会发现这个答案以足够的信息使用耶拿来解决你的问题,但如果不是,一些讨论是为了解析schema.org TTL / OWL文件。

首先,请注意,在OWL属性是不是同一种东西作为一种面向对象的编程语言属性。这意味着我们我们说一个属性P具有域D是,当我们看到其财产为P的声明中,我们可以推断,主体是类型D的作为一项规则,这是:

  X P Y [P RDFS:域D
--------------------------
    点¯xRDF:D型

但考虑这意味着什么。若D是C的子类,那么我们可以从推断 X RDF:D型的 X RDF:C型 。这意味着 C 的P的领域(这是OWL的情况,但纯粹的RDF有一个稍微不同的语义。)因此,如果你问什么属性有C类为域,你会得到对C亚类领域,除了拥有C作为域类的属性。

如果你想要一种面向对象的类和属性来看,你可以使用耶拿方法OntClass#listDeclaredProperties。


  

listDeclaredProperties

  com.hp.hpl.jena.util.iterator.ExtendedIterator< OntProperty> listDeclaredProperties(布尔直接)


  
  

返回一个迭代过与框状相关联的属性
  针对这一类。这抓住了一个直观的概念
  一类的属性。这可以psenting本体是$ P $有用
  类中的用户界面,例如通过自动构建一个
  形成实例化的类的实例。在属性
  类的帧的视图通过比较的域确定的
  在这个类的OntModel与类本身的属性。看到:
  [presenting RDF作为帧] [2]了解更多详情。


  
  

请注意确定属性是否被相关的,很多情况下,
  一类依赖于RDFS或OWL推理。这种方法可以
  因此,只有在有一个附带的模式返回完整的结果
  推理。


  
  

参数:


  
  

      
  • 直接 - 如果为true,限制属性返回那些直接与此类关联。如果为false,超类的属性
      这个类的不会的这个声明的属性中上市
      类。

  •   

  
  

返回:


  
  

这是由它们的域名与此类相关的属性的迭代。


How can I determine object properties for a class in Jena . I can get the all objects properties, but I want to get the object properties for a particular class.

Code for getting all the objectProperties:

 ExtendedIterator objects = m.listObjectProperties();

  while (objects.hasNext()) 
       {
            Property essaProperty = (Property) objects.next();            
            System.out.println("Propiedad: " + essaProperty.getLocalName());

       }

Also, how I can get the related class to the object property, I mean, knowing A how I can get the object property "---->" and how I can get "B"

                                  has  
                             (A---------->B)

Thanks

解决方案

You might find enough information in this answer to Parsing schema.org ttl/owl file using Jena to solve your problem, but if not, some discussion is in order.

First, note that properties in OWL are not the same kind of thing as "properties" in an object-oriented programming languages. What it means we we say that a property P has a domain D is that when we see a statement whose property is P, we can infer that the subject is of type D. As a rule, this is:

x P y      P rdfs:domain D
--------------------------
    x rdf:type D

But consider what this means. If D is a subclass of C, then we can infer from x rdf:type D that x rdf:type C. This means that C is also a domain of P. (This is the case in OWL, but pure RDF has a slightly different semantics.) Thus, if you're asking "what properties have class C as a domain", you'll get the properties that have subclasses of C as domains, in addition to classes that have C as a domain.

If you do want a sort of "object-oriented" view of the classes and properties, you can use the Jena method OntClass#listDeclaredProperties.

listDeclaredProperties

com.hp.hpl.jena.util.iterator.ExtendedIterator<OntProperty> listDeclaredProperties(boolean direct)

Return an iterator over the properties associated with a frame-like view of this class. This captures an intuitive notion of the properties of a class. This can be useful in presenting an ontology class in a user interface, for example by automatically constructing a form to instantiate instances of the class. The properties in the frame-like view of the class are determined by comparing the domain of properties in this class's OntModel with the class itself. See: [Presenting RDF as frames][2] for more details.

Note that many cases of determining whether a property is associated with a class depends on RDFS or OWL reasoning. This method may therefore return complete results only in models that have an attached reasoner.

Parameters:

  • direct - If true, restrict the properties returned to those directly associated with this class. If false, the properties of super-classes of this class will not be listed among the declared properties of this class.

Returns:

An iteration of the properties that are associated with this class by their domain.

这篇关于对象属性的一类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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