Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

restrict xsd:string to [A-Z] for rdfs:range

Tags:

rdf

owl

rdfs

How can I specify the range of a datatype property to be xsd:strings whose literal forms match [A-Z]? OWL restrictions don't do the trick for me, at least at first glance. Is there a way to do this with regular expressions and if so, where?

like image 257
chile Avatar asked May 24 '13 08:05

chile


3 Answers

I suppose you mean "single capital letter" which is string[pattern "[A-Z]"].

If you are using Protege, enter this into the "Data range expression" tab.

HermiT 1.3.7 can check this and provide explanations about inconsistent property values.

like image 101
utapyngo Avatar answered Oct 17 '22 16:10

utapyngo


Other answers have explained that this can be done using the XSD facets to restrict the string range of the property to those matching the pattern [A-Z], but none showed the resulting RDF. I created a very simple ontology in Protégé and defined a data property hasLatinInitial. As other answers described, the range was specified as string[pattern "[A-Z]"]. Then I created an individual JohnDoe and added the data property assertions that

JohnDoe hasLatinInitial "J" .
JohnDoe hasLatinInitial "D" .

and HermiT 1.3.7 indeed ran and reported no inconsistency. I then added the assertion

JohnDoe hasLatinInitial "3" .

and HermiT 1.3.7 reported an inconsistency:

enter image description here

Here's what the resulting ontology looks like in N3 and in RDF/XML:

@prefix :        <http://www.example.com/example#> .
@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#> .
@prefix example:  <http://www.example.com/example#> .

<http://www.example.com/example>
      a       owl:Ontology .

example:hasLatinInitial
      a       owl:DatatypeProperty ;
      rdfs:range
              [ a       rdfs:Datatype ;
                owl:onDatatype xsd:string ;
                owl:withRestrictions
                        ([ xsd:pattern "[A-Z]"
                          ])
              ] .

example:JohnDoe
      a       owl:NamedIndividual ;
      example:hasLatinInitial
              "3" , "J" , "D" 
<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:example="http://www.example.com/example#"
    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://www.example.com/example"/>
  <owl:DatatypeProperty rdf:about="http://www.example.com/example#hasLatinInitial">
    <rdfs:range>
      <rdfs:Datatype>
        <owl:onDatatype rdf:resource="http://www.w3.org/2001/XMLSchema#string"/>
        <owl:withRestrictions rdf:parseType="Collection">
          <rdf:Description>
            <xsd:pattern>[A-Z]</xsd:pattern>
          </rdf:Description>
        </owl:withRestrictions>
      </rdfs:Datatype>
    </rdfs:range>
  </owl:DatatypeProperty>
  <owl:NamedIndividual rdf:about="http://www.example.com/example#JohnDoe">
    <example:hasLatinInitial>3</example:hasLatinInitial>
    <example:hasLatinInitial>D</example:hasLatinInitial>
    <example:hasLatinInitial>J</example:hasLatinInitial>
  </owl:NamedIndividual>
</rdf:RDF>

like image 24
Joshua Taylor Avatar answered Oct 17 '22 15:10

Joshua Taylor


The following expression in Manchester syntax should do the trick:

string[pattern "A-Z"]

You can put it straight as data range in Protege. I'm not sure what reasoners are implementing the construct though, I've never used it before.

More information on it: http://www.w3.org/TR/owl2-manchester-syntax/#facet

like image 22
loopasam Avatar answered Oct 17 '22 14:10

loopasam