parsa
parsa

Reputation: 49

Creating relations between classes in web ontology language(owl)

I need to define relations between classes in my ontology in OWL syntax. what should i do?

Upvotes: 2

Views: 1556

Answers (2)

Antoine Zimmermann
Antoine Zimmermann

Reputation: 5485

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. 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: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, e.g.:

<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. Here, #Node is declared as both a class and an instance of 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. In OWL DL, the context in which an IRI appear always makes it clear what the term refers to.

Upvotes: 2

cygri
cygri

Reputation: 9472

First, note that there are two XML syntaxes (in addition to several other non-XML syntaxes) that you can use to write OWL. Your snippet is in RDF/XML syntax. The other syntax is OWL/XML. The OWL Primer has examples of both syntaxes.

Your snippet says:

  • The URI <#net> identifies a class.
  • This class has the label “network” (a string).
  • This class is in a “hasPart” relationship with something that is identified by the URI <#Node>.

The first two things make sense, but the last one doesn't really. I guess what you really want to say is:

  • The URI <#Node> also identifies a class.
  • The URI <#hasPart> identifies a property that connects individuals of two classes (an owl:ObjectProperty).
  • The subjects of the hasPart property are networks (in other words, the domain of hasPart is #net).
  • The objects of the hasPart property are nodes (in other words, the range of hasPart is #node).

Looking at the examples in the OWL Primer should give you a decent idea how to write these things down. But also note that writing the RDF/XML syntax by hand is tedious and error-prone. You probably want to use an OWL editor like TopBraid Composer, or a programming library like OWL-API, to create your OWL files. 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.

Upvotes: 2

Related Questions