[英]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: 您的片段说:
<#net>
identifies a class. <#net>
标识一个类。 <#Node>
. <#Node>
标识的内容具有“ hasPart”关系。 The first two things make sense, but the last one doesn't really. 前两件事是有道理的,但最后一件事却没有。 I guess what you really want to say is:
我想您真正想说的是:
<#Node>
also identifies a class. <#Node>
也标识一个类。 <#hasPart>
identifies a property that connects individuals of two classes (an owl:ObjectProperty
). <#hasPart>
标识连接两个类( owl:ObjectProperty
)的个体的属性。 #net
). #net
)。 #node
). #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.