如何为OWL数据属性定义我自己的范围 [英] How to Define My Own Ranges for OWL DataProperties
问题描述
我最近开始学习Web本体语言(OWL).我想用自己定义的值范围定义一个DataProperty. 考虑以下属性:
I have recently started learning Web Ontology Language (OWL). I want to define a DataProperty with my own defined range of value. Consider the following property:
<owl:DatatypeProperty rdf:ID="myProperty">
<rdfs:domain rdf:resource="#MyDomain"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#double"/>
</owl:DatatypeProperty>
该属性具有double值的范围,但我想限制该范围,以便使我的属性仅接受0到1之间的double值.如果您指导我如何定义自己的范围,我将不胜感激数据属性.
The property has the range of double value but I want to restrict the range in order to make my property to accept only double values between 0 and 1. I would be very grateful if you guide me how to define my own ranges for data properties.
推荐答案
在这里(为简洁起见,使用Turtle而不是RDF/XML):
Here you go (in Turtle rather than RDF/XML, for conciseness):
:myProperty a owl:DatatypeProperty;
rdfs:domain :MyDomain;
rdfs:range [
a rdfs:Datatype;
owl:onDatatype xsd:double;
owl:withRestrictions ( [xsd:minInclusive 0] [xsd:maxInclusive 1] )
] .
我建议您使用xsd:decimal
而不是xsd:double
,因为xsd:double
的精度有限并且与xsd:decimal
不相交,这也使其与xsd:integer
,xsd:int
等不相交.
I would suggest that you use xsd:decimal
instead of xsd:double
, because xsd:double
is limited in precision and is disjoint from xsd:decimal
, which also makes it disjoint from xsd:integer
, xsd:int
, etc.
更新:在RDF/XML中,它对应于(看看它与Turtle相比有多混乱):
UPDATE: in RDF/XML, it corresponds to (look at how messy it is compared to Turtle):
<owl:DatatypeProperty rdf:about="#myProperty">
<rdfs:domain rdf:resource="#MyDomain"/>
<rdfs:range>
<rdfs:Datatype>
<owl:onDatatype rdf:resource="&xsd;double"/>
<owl:withRestrictions rdf:parseType="Collection">
<rdf:Description>
<xsd:minInclusive rdf:datatype="&xsd;double">0</xsd:minInclusive>
</rdf:Description>
<rdf:Description>
<xsd:maxInclusive rdf:datatype="&xsd;double">1</xsd:maxInclusive>
<rdf:Description>
</rdf:Description>
</owl:withRestrictions>
</rdfs:Datatype>
</rdfs:range>
</owl:DatatypeProperty>
但是,如果您直接使用文本编辑器编写RDF,则应该真正学会使用 Turtle .它比RDF/XML更简单,更简洁.您真的可以看到三元组.而且这将很快成为标准,向W3C候选推荐标准的转变迫在眉睫.
But if you are writing RDF directly with a text editor, you should really learn to use Turtle. It's much simpler and more concise than RDF/XML. You can really see the triples. And it's going to be a standard soon, the move to W3C Candidate Recommendation is imminent.
** 2017年10月3日更新:乌龟于2014年2月标准化.如果您更喜欢基于JSON的RDF表示法,那么还有 JSON-LD ,另一个W3C标准.
**Update October 3rd, 2017: Turtle was standardised in February 2014. If you prefer a notation for RDF based on JSON, there is also JSON-LD, another W3C standard.
这篇关于如何为OWL数据属性定义我自己的范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!