In an ontology, how to define a property's value as a datetime
Asked Answered
I

1

6

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?

Imperative answered 31/1, 2014 at 17:27 Comment(0)
W
5

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(<https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects>

Declaration(Class(<https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects#Project>))
Declaration(DataProperty(<https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects#dueDate>))
DataPropertyDomain(<https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects#dueDate> <https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects#Project>)
DataPropertyRange(<https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects#dueDate> xsd:dateTime)
)

The important axiom is

DataPropertyRange(<https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/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 :      <https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/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#> .

<https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/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="https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/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="https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects"/>
  <owl:Class rdf:about="https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects#Project"/>
  <owl:DatatypeProperty rdf:about="https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects#dueDate">
    <rdfs:domain rdf:resource="https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/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="https://mcmap.net/q/1760380/-in-an-ontology-how-to-define-a-property-39-s-value-as-a-datetime/1281433/projects#dueDate">
    <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#dateTime"/>
  </owl:DatatypeProperty>
Waterspout answered 31/1, 2014 at 21:10 Comment(2)
Thank you. i wasn't really concerned about the language in which to write it, but rather which ont:prop was the most widely accepted / best datetime definition. To that, your answer was http://www.w3.org/2001/XMLSchema#dateTime aka xsd:dateTime, and that's exactly what I was hoping to get! :) As a sidenote, I intentionally wrote the question this way because "most appropriate" or "best" questions are often marked off-topic on SO.Imperative
Hi, I've a slight confusion with OWL Time, this is the only question on stackoverflow related to OWL Time, so I though of putting the link here just if you can help, thanks #36402661Cornetcy

© 2022 - 2024 — McMap. All rights reserved.