Search code examples
rdfowlreasoningstardogturtle-rdf

Reasoning and datatypes of Literals


In Turtle-RDF it is convenient to omit the datatype extension ^^xsd:string for string literals. But when i try to do reasoning with StarDog, http://www.stardog.com/, only the individual :YYY with the extension "green"^^xsd:string is found to be a :GreenButton

@prefix :      <http://stackoverflow.com/q/29075078/1281433#> .
@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#> .


:color   a            owl:DatatypeProperty ;
         rdfs:range   xsd:string ;
         rdfs:domain  :Button .


:XXX     :color       "green"             .
:YYY     :color       "green"^^xsd:string .


:Button         a     rdfs:Class .

:GreenButton    a     rdfs:Class ;
                owl:equivalentClass [ a owl:Restriction;
                                      owl:onProperty :color ;
                                      owl:hasValue "green"
                                    ] .

:TestButton     a     :GreenButton .

Reasoning result:

+-------------+----------+----------------------------------------------------+
|      s      |    p     |         o                                          |
+-------------+----------+----------------------------------------------------+
| :XXX        | rdf:type | :Button                                            |
| :YYY        | rdf:type | :Button                                            |
| :YYY        | rdf:type | :GreenButton                                       |

| :TestButton | rdf:type | :GreenButton                                       |
| :TestButton | :color   | "green"^^<http://www.w3.org/2001/XMLSchema#string> |
  ...

What is the best way to deal with it?


Solution

  • According to the docs:

    RDF parsing in Stardog is strict: it requires typed RDF literals to match their explicit datatypes, URIs to be well-formed, etc. In some cases, strict parsing isn’t ideal—it may be disabled using the --strict-parsing=FALSE.

    However, even with strict parsing disabled, Stardog’s RDF parser may encounter parse errors from which it cannot recover. And loading data in lax mode may lead to unexpected SPARQL query results. For example, malformed literals ("2.5"^^xsd:int) used in filter evaluation may lead to undesired results.

    Have you tried disabling strict-parsing and see what the effects are?

    p.s. see Joshua's comment in the question. I am not advising to switch off strict parsing, but it may be the only option if dealing with arbitrary/external data that is sparsely typed (assuming it does resolve the issue).