10

I am adding few new DataType in the OWL using Protege.

The DataType is like percentage and I want to specify it's range with the double value ranging from 0 to 100.

Similarly a DataType named Quality and I want to specify it's range with the double value ranging from 0 to 1.

How can we specify these things in the Data range Expression ?

I tried to find out but I found two links but not useful in my context.

  1. How to Define My Own Ranges for OWL DataProperties This is useful if we are manually creating the OWL file and not using Protege.

  2. http://answers.semanticweb.com/questions/16541/datatype-property-protege This is related to the context when we don't have the option of adding the new data type.

Please help how to write the Data range expression for these scenario in Protege

Scenario: enter image description here

Stanislav Kralin
  • 10,115
  • 4
  • 30
  • 52
Gaurav
  • 491
  • 1
  • 4
  • 15

2 Answers2

14

It's just xsd:double[ >= 0, <= 100 ].

screenshot

<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns="http://stackoverflow.com/q/24531940/1281433/percentages#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#">
  <owl:Ontology rdf:about="http://stackoverflow.com/q/24531940/1281433/percentages"/>
  <owl:DatatypeProperty rdf:about="http://stackoverflow.com/q/24531940/1281433/percentages#hasPercentage">
    <rdfs:range>
      <rdfs:Datatype>
        <owl:onDatatype rdf:resource="http://www.w3.org/2001/XMLSchema#double"/>
        <owl:withRestrictions rdf:parseType="Collection">
          <rdf:Description>
            <xsd:minInclusive rdf:datatype="http://www.w3.org/2001/XMLSchema#integer"
            >0</xsd:minInclusive>
          </rdf:Description>
          <rdf:Description>
            <xsd:maxInclusive rdf:datatype="http://www.w3.org/2001/XMLSchema#integer"
            >100</xsd:maxInclusive>
          </rdf:Description>
        </owl:withRestrictions>
      </rdfs:Datatype>
    </rdfs:range>
  </owl:DatatypeProperty>
</rdf:RDF>
@prefix :      <http://stackoverflow.com/q/24531940/1281433/percentages#> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .

:hasPercentage  a   owl:DatatypeProperty ;
        rdfs:range  [ a                     rdfs:Datatype ;
                      owl:onDatatype        xsd:double ;
                      owl:withRestrictions  ( [ xsd:minInclusive
                                        0 ] [ xsd:maxInclusive  100 ] )
                    ] .

<http://stackoverflow.com/q/24531940/1281433/percentages>
        a       owl:Ontology .
Joshua Taylor
  • 80,876
  • 9
  • 135
  • 306
  • Though it's not a part of this question, If we are defining any data object as the type of cutom data type can be also validate it against the range we have given ? – Gaurav Jul 02 '14 at 17:52
  • The datatype is actually the double but the minInclusive and maxInclusive are having datatype as the integer. Shouldn't there should be double also ? Do we need to define like double [>=0.00, <=100.00] ? – Gaurav Jul 02 '14 at 17:57
  • Oh, that's a good point. I'm not sure how the conversion from ints to doubles is done. It's probably safer to use `double[>= 0.0, <= 0.0]`. Some reasoners will do datatype reasoning. E.g., Pellet would say it's inconsistent if you declare `x hasPercentage 101.0`. – Joshua Taylor Jul 02 '14 at 18:10
  • Though it works for me, Actually the question was about adding the data type but you have add the example for the Data property. – Gaurav Jul 02 '14 at 19:42
  • I'm not sure exactly what you mean. The way to represent a data range is something like `double[>= 0, <= 100]`. That's the same whether you're using it in a class restriction, or as a property range, or anywhere else. You said that you "want to specify … range with [a] double value ranging from 0 to 100." The only things that have ranges are properties. – Joshua Taylor Jul 02 '14 at 19:48
  • Actually I am adding new data type like double, ints and in the Datatype definition I am defining the Range for that data type. There is option of specifying Data Type Range expression. – Gaurav Jul 02 '14 at 20:10
  • I don't know what you mean. Datatypes don't *have* ranges; they *are* ranges. `double[...]` is a datatype like double, but with a smaller set of permissible values. – Joshua Taylor Jul 02 '14 at 20:11
  • I have edited the answer and added the image which explain what I actually want to say. – Gaurav Jul 02 '14 at 20:23
  • @Gaurav Ah, I see. I didn't realize that Protege lets you define datatypes like that. That's handy, though I don't know whether reasoners will recognize the custom datatypes (even if they recognize the faceted datatypes), so use caution and test early! – Joshua Taylor Jul 02 '14 at 20:45
2

This post might be helpful to those who would like to assign discrete integer (or any data type) values as the range of the data type property. Type the following code in the data range expression editor:

{"0"^^xsd:int , "1"^^xsd:int , "10"^^xsd:int , "18"^^xsd:int , "2"^^xsd:int , "3"^^xsd:int , "4"^^xsd:int , "5"^^xsd:int , "6"^^xsd:int , "8"^^xsd:int}
Sreekar
  • 33
  • 6