문제

When writing an ontology and you want to create a class and property relating to a time/date, I assume that you'll have something structurally like this (psuedo code):

class:Project
  label: Project

property:duedate
  label: The expected completion time and date of project
  domain: Project
  range: datetime (?)

i've googled around and found the Owl-Time ontology, but the use case is confusing to me because it looks like I'm supposed to define quite a few things. Am I on the right track here?

도움이 되었습니까?

해결책

You haven't mentioned how you're constructing your ontology. If you're writing OWL by hand (e.g., with the functional syntax), then you'd do it one way; if you're writing RDF, then you'll do it another (you'd write the RDF encoding of the OWL axiom). Probably the easiest way to see how these are done is by defining the ontology using Protégé, or a similar graphical editor, and then look at the resulting code. I assume that since you used the term datetime, you're look at a data property whose values should be literals of the datatype xsd:dateTime.

In Protégé

In Protégé you'd do something like this:

enter image description here

In the OWL Functional Syntax

The syntax for data property range axioms is given in 9.3.5 Data Property Range from the OWL 2 Web Ontology Language Structural Specification and Functional-Style Syntax (Second Edition). When we save the ontology in the functional syntax, we get this:

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)
)

The important axiom is

DataPropertyRange(<http://stackoverflow.com/q/21486301/1281433/projects#dueDate> xsd:dateTime)

In RDF

OWL can be serialized in RDF, and RDF can be serialized in a number of ways. Here's what that ontology looks like in the Turtle serialization of RDF, and in the RDF/XML serialization:

@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 .

The important triple, of course, is

: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>

It's still the same triple that's important here, but in this format it's written as:

  <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>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top