简体   繁体   English

在Web本体语言中创建类之间的关系(猫头鹰)

[英]Creating relations between classes in web ontology language(owl)

I need to define relations between classes in my ontology in OWL syntax. 我需要使用OWL语法在本体中定义类之间的关系。 what should i do? 我该怎么办?

First, note that there are two XML syntaxes (in addition to several other non-XML syntaxes) that you can use to write OWL. 首先,请注意,可以使用两种XML语法(除了其他几种非XML语法)来编写OWL。 Your snippet is in RDF/XML syntax. 您的代码段采用RDF / XML语法。 The other syntax is OWL/XML. 另一种语法是OWL / XML。 The OWL Primer has examples of both syntaxes. OWL入门手册提供了两种语法的示例。

Your snippet says: 您的片段说:

  • The URI <#net> identifies a class. URI <#net>标识一个类。
  • This class has the label “network” (a string). 此类具有标签“网络”(字符串)。
  • This class is in a “hasPart” relationship with something that is identified by the URI <#Node> . 此类与URI <#Node>标识的内容具有“ hasPart”关系。

The first two things make sense, but the last one doesn't really. 前两件事是有道理的,但最后一件事却没有。 I guess what you really want to say is: 我想您真正想说的是:

  • The URI <#Node> also identifies a class. URI <#Node>也标识一个类。
  • The URI <#hasPart> identifies a property that connects individuals of two classes (an owl:ObjectProperty ). URI <#hasPart>标识连接两个类( owl:ObjectProperty )的个体的属性。
  • The subjects of the hasPart property are networks (in other words, the domain of hasPart is #net ). hasPart属性的主题是网络(换句话说,hasPart的域是#net )。
  • The objects of the hasPart property are nodes (in other words, the range of hasPart is #node ). hasPart属性的对象是节点(换句话说,hasPart的范围是#node )。

Looking at the examples in the OWL Primer should give you a decent idea how to write these things down. 查看OWL Primer中的示例应该可以使您有一个不错的主意,如何将这些内容记下来。 But also note that writing the RDF/XML syntax by hand is tedious and error-prone. 但也请注意,手动编写RDF / XML语法既繁琐又容易出错。 You probably want to use an OWL editor like TopBraid Composer, or a programming library like OWL-API, to create your OWL files. 您可能想要使用诸如TopBraid Composer之类的OWL编辑器,或诸如OWL-API之类的编程库来创建OWL文件。 If you really want to write them by hand, I recommend using Turtle syntax (again, the Primer has examples), because it's much more readable, and gives you a head start towards learning SPARQL, the query language for OWL and RDF. 如果您真的想手工编写它们,我建议您使用Turtle语法(同样,Primer包含示例),因为它更具可读性,并且使您开始学习SPARQL(OWL和RDF的查询语言)。

I agree with cygri that relating #net to #Node like this does not seem to make sense, and probably you'd like that all instances of #net have a part or some parts that are instances of #Node . 我同意cygri的#net#Node像这样将#Node#net #Node似乎没有任何意义,并且您可能希望#net所有实例都有一部分或某些部分是#Node实例。 To do this, you can write: 为此,您可以编写:

<owl:Class rdf:ID="Node"/>
<owl:Class rdf:ID="net">
    <rdfs:subClassOf>
        <owl:Restriction>
            <owl:onProperty rdf:resource="#hasPart"/>
            <owl:someValuesFrom rdf:resource="#Node"/>
        </owl/Restriction>
    </rdfs:subClassOf>
</owl:Class>

You may still want to define properties that connect two classes directly. 您可能仍想定义直接连接两个类的属性。 For instance: 例如:

<#Node>  <#isSimilarTo>  <#Vertice> .

To do this in OWL, you can define an owl:AnnotationProperty : 要在OWL中执行此操作,可以定义owl:AnnotationProperty

<owl:AnnotationProperty rdf:about="isSimilarTo"/>
<owl:Class rdf:ID="Node">
    <isSimilarTo rdf:resource="#Vertice"/>
</owl:Class>

Or you can use "punning", that is, use a class as an instance, eg: 或者,您可以使用“ punning”,即使用一个类作为实例,例如:

<owl:ObjectProperty rdf:about="isSimilarTo"/>
<owl:Class rdf:ID="Node">
    <rdf:type rdf:resource="&owl;Thing"/>
    <isSimilarTo>
        <owl:Thing rdf:about="#Vertice"/>
    </isSimilarTo>
</owl:Class>

Note that in OWL DL, all instances must be explicitly typed. 请注意,在OWL DL中,必须实例化所有实例。 Here, #Node is declared as both a class and an instance of owl:Thing . 在这里, #Node被声明为owl:Thing的类和实例。 This does not mean that owl:Thing can contain classes, but it means that #Node refer to two distinct things: a class and an instance. 这并不意味着owl:Thing可以包含类,而是意味着#Node引用两个不同的事物:类和实例。 In OWL DL, the context in which an IRI appear always makes it clear what the term refers to. 在OWL DL中,IRI出现的上下文总是使该术语所指清楚。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM