OWL: restricting a property value to a numeric string

There are things with string properties in my database. Some property values ​​correspond to numeric strings (contain only numbers). I would like to give these things a special type (a subtype of what they are). Is this possible in OWL?

+3
source share
2 answers

I think you need Datatype Restrictionsto combine with xsd:pattern.

The next axiom from OWL 2 Primer ...

:Teenager  rdfs:subClassOf
       [ rdf:type             owl:Restriction ;
         owl:onProperty       :hasAge ;
         owl:someValuesFrom   
          [ rdf:type             rdfs:Datatype ;
            owl:onDatatype       xsd:integer ;
            owl:withRestrictions (  [ xsd:minExclusive     "12"^^xsd:integer ]
                                    [ xsd:maxInclusive     "19"^^xsd:integer ]
            )
          ]
       ] .

... and if you change it a bit with xsd:pattern, we can have something like ...

:YourClass  rdfs:subClassOf
       [ rdf:type             owl:Restriction ;
         owl:onProperty       :yourHasNumericProperty ;
         owl:someValuesFrom   
          [ rdf:type             rdfs:Datatype ;
            owl:onDatatype       xsd:integer ;
            owl:withRestrictions  ([xsd:pattern "E[1-9][0-9]*"])
          ]
       ] .

With the help of xsd:patternyou can perform data type restriction based on regular expressions.

, .

+2

RDF. RDF - ( /RDF )...

@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
:x :myDataTypeProperty "123"^^xsd:integer .
:y :myDataTypeProperty "some string"^^xsd:string .
:z :myDataTypeProperty "2004-12-06"^^xsd:date .

RDF/XML

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:xsd="http://www.w3.org/2001/XMLSchema#" xmlns="http://www.foo.bar.com#">
  <rdf:Description rdf:about="http://www.foo.bar.com#x">
    <myDataTypeProperty rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">123</myDataTypeProperty>
  </rdf:Description>
  <rdf:Description rdf:about="http://www.foo.bar.com#y">
    <myDataTypeProperty rdf:datatype="http://www.w3.org/2001/XMLSchema#string">some string</myDataTypeProperty>
  </rdf:Description>
  <rdf:Description rdf:about="http://www.foo.bar.com#z">
    <myDataTypeProperty rdf:datatype="http://www.w3.org/2001/XMLSchema#date">2004-12-06</myDataTypeProperty>
  </rdf:Description>
</rdf:RDF>

XMLSchema (XSD) . , , SPARQL

- :

:x :myDataTypeProperty "123"^^ns:MyClassificationScheme .

, ...

ns:MyClassificationScheme rdfs:subClassOf xsd:integer .

SPARQL , , :

SELECT * WHERE { 
   ?person :born ?birthDate .
   FILTER ( ?birthDate > "2005-02-28"^^xsd:date ) .
}

, .

Edited

, . .

0

Source: https://habr.com/ru/post/1772273/


All Articles