在编写本体时,如果你想创建一个与时间/日期有关的类和属性,我假设你会在结构上有类似(伪代码)的东西:
class:Project
label: Project
property:duedate
label: The expected completion time and date of project
domain: Project
range: datetime (?)
我用Google搜索并找到Owl-Time本体,但use case对我来说很困惑,因为看起来我应该定义很多东西。我在这里走在正确的轨道上吗?
答案 0 :(得分:5)
您还没有提到过如何构建本体。如果您是手工编写OWL(例如,使用函数语法),那么您可以单向执行;如果您正在编写RDF,那么您将另外执行(您将编写OWL公理的RDF编码)。查看这些操作的最简单方法可能是使用Protégé或类似的图形编辑器定义本体,然后查看生成的代码。我假设你使用了术语datetime,你会看到一个数据属性,其值应该是数据类型xsd:dateTime
的文字。
在Protégé你会做这样的事情:
数据属性范围公理的语法在9.3.5 Data Property Range的OWL 2 Web Ontology Language Structural Specification and Functional-Style Syntax (Second Edition)中给出。当我们在函数语法中保存本体时,我们得到了这个:
Prefix(xsd:=<http://www.w3.org/2001/XMLSchema#>)
Prefix(owl:=<http://www.w3.org/2002/07/owl#>)
Prefix(xml:=<http://www.w3.org/XML/1998/namespace>)
Prefix(rdf:=<http://www.w3.org/1999/02/22-rdf-syntax-ns#>)
Prefix(rdfs:=<http://www.w3.org/2000/01/rdf-schema#>)
Ontology(<http://stackoverflow.com/q/21486301/1281433/projects>
Declaration(Class(<http://stackoverflow.com/q/21486301/1281433/projects#Project>))
Declaration(DataProperty(<http://stackoverflow.com/q/21486301/1281433/projects#dueDate>))
DataPropertyDomain(<http://stackoverflow.com/q/21486301/1281433/projects#dueDate> <http://stackoverflow.com/q/21486301/1281433/projects#Project>)
DataPropertyRange(<http://stackoverflow.com/q/21486301/1281433/projects#dueDate> xsd:dateTime)
)
重要的公理是
DataPropertyRange(<http://stackoverflow.com/q/21486301/1281433/projects#dueDate> xsd:dateTime)
OWL可以在RDF中序列化,RDF可以通过多种方式序列化。这是本体在RDF的Turtle序列化和RDF / XML序列化中的样子:
@prefix : <http://stackoverflow.com/q/21486301/1281433/projects#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
<http://stackoverflow.com/q/21486301/1281433/projects>
a owl:Ontology .
:Project a owl:Class .
:dueDate a owl:DatatypeProperty ;
rdfs:domain :Project ;
rdfs:range xsd:dateTime .
当然,重要的三重奏是
:dueDate rdfs:range xsd:dateTime
<rdf:RDF
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns="http://stackoverflow.com/q/21486301/1281433/projects#"
xmlns:owl="http://www.w3.org/2002/07/owl#"
xmlns:xsd="http://www.w3.org/2001/XMLSchema#"
xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#">
<owl:Ontology rdf:about="http://stackoverflow.com/q/21486301/1281433/projects"/>
<owl:Class rdf:about="http://stackoverflow.com/q/21486301/1281433/projects#Project"/>
<owl:DatatypeProperty rdf:about="http://stackoverflow.com/q/21486301/1281433/projects#dueDate">
<rdfs:domain rdf:resource="http://stackoverflow.com/q/21486301/1281433/projects#Project"/>
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#dateTime"/>
</owl:DatatypeProperty>
</rdf:RDF>
它仍然是重要的三重奏,但在这种格式中,它写成:
<owl:DatatypeProperty rdf:about="http://stackoverflow.com/q/21486301/1281433/projects#dueDate">
<rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#dateTime"/>
</owl:DatatypeProperty>