owlcs / owlapi

OWL API main repository
830 stars 315 forks source link

Datatype in both sets: classes and datatypes #434

Closed BlackDark closed 9 years ago

BlackDark commented 9 years ago

Hey,

i encountered a problem during converting ontolgies for the webvowl visualization. Currently i supposed that the entities are unique and cannot be found in both sets:

.getClassesInSignature() and .getDatatypesInSignature()

But for at least some constructs i have this problem. Here is the sample ontology:

@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .

@prefix this: <http://testing#> .

this:DivisibleByTwoEnumeration a rdfs:Datatype ;
    owl:equivalentClass [
        a rdfs:Datatype ;
        owl:oneOf ( 2 4 6 8 10 12 14 16 18 20 )
    ].

this:ComplementDatatype a rdfs:Datatype ;
    owl:complementOf this:DivisibleByTwoEnumeration .

this:complementTypeDatatypeProperty a owl:DatatypeProperty ;
    rdfs:range this:ComplementDatatype ;
    rdfs:label "complement-type datatype property" .    

Both datatypes DivisibleByTwoEnumeration and ComplementDatatype do appear in both sets. Same issue with DataIntersections and DataUnions.

Is it supposed to be like that or a bug?

Thanks in advance!

Edit: This is the output for getClassesInSignature and then getDatatypesInSignature:

[<http://testing#DivisibleByTwoEnumeration>, <http://testing#ComplementDatatype>]

[<http://testing#DivisibleByTwoEnumeration>, http://www.w3.org/2001/XMLSchema#integer, http://www.w3.org/1999/02/22-rdf-syntax-ns#PlainLiteral, <http://testing#ComplementDatatype>]
matthewhorridge commented 9 years ago

Shouldn't

this:ComplementDatatype a rdfs:Datatype ;
    owl:complementOf this:DivisibleByTwoEnumeration .

be

this:ComplementDatatype a rdfs:Datatype ;
    owl:datatypeComplementOf this:DivisibleByTwoEnumeration .

?

BlackDark commented 9 years ago

Ahh, thanks a lot. Seems we had some bugs in the data itself! That fixed the problems.

BlackDark commented 9 years ago

Still have problems with datatypes in both sets.

The syntax for union and intersection does not change as i see in the specification.


this:DivisibleByTwoEnumeration a rdfs:Datatype ;
    owl:equivalentClass [
        a rdfs:Datatype ;
        owl:oneOf ( 2 4 6 8 10 12 14 16 18 20 )
    ].

this:DivisibleByFiveEnumeration a rdfs:Datatype ;
    owl:equivalentClass [
        a rdfs:Datatype ;
        owl:oneOf ( 5 10 15 20 )
    ].

this:UnionDatatype a rdfs:Datatype ;
    owl:unionOf ( this:DivisibleByTwoEnumeration this:DivisibleByFiveEnumeration ).

this:IntersectionDatatype a rdfs:Datatype ;
    owl:intersectionOf ( this:DivisibleByTwoEnumeration this:DivisibleByFiveEnumeration ).

this:ComplementDatatype a rdfs:Datatype ;
    owl:datatypeComplementOf this:DivisibleByTwoEnumeration .

Or are there also problems in the syntax?

And shouldn't there be an axiom for the complementOf in the dataype? This axioms are currently there (called with .getReferencingAxioms(ontology)):

--- <http://ontovibe.visualdataweb.org#ComplementDatatype>
Declaration(Datatype(<http://ontovibe.visualdataweb.org#ComplementDatatype>))

Sorry for troublemaking :)

ignazio1977 commented 9 years ago

Punning between classes and datatypes is not allowed in OWL 2 http://www.w3.org/TR/owl2-new-features/#Simple_metamodeling_capabilities This does not mean the OWL API will disallow it, but it should come up as an OWL 2 DL violation when using the Profiles validation. Whether in this case we're seeing an input ontology using punning, or the effect of a bug, I'll have to replicate and debug to be sure.

ignazio1977 commented 9 years ago

Looks like we got a bug.

Declaration(Datatype(<http://testing#UnionDatatype>))
EquivalentClasses(<http://testing#UnionDatatype> ObjectUnionOf(<http://testing#DivisibleByFiveEnumeration> <http://testing#DivisibleByTwoEnumeration>) )

These are two axioms as parsed by OWLAPI 4.1.0 (first Turtle parser found by default). According to the OWL mapping to RDF, the ObjectUnionOf expression should be a DataUnionOf. All IRIs have their declarations in the RDF fragment, so to me the input looks correct, but the result of parsing isn't as expected.

I'll try the RIO parser to make sure which parser is producing this result, since we have two Turtle parsers available.

ignazio1977 commented 9 years ago

Same with both parsers

ignazio1977 commented 9 years ago

I was mistaken: the syntax is not the expected RDF. I've tried defining an ontology to match the intent in the input and saved and parsed it again correctly:

@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@base <http://www.w3.org/2002/07/owl#> .
<urn:test:data1> rdf:type rdfs:Datatype ;
             owl:equivalentClass xsd:integer .
<urn:test:data2> rdf:type rdfs:Datatype ;
             owl:equivalentClass xsd:int .
<urn:test:data3> rdf:type rdfs:Datatype ;
             owl:equivalentClass [ rdf:type rdfs:Datatype ;
                                   owl:unionOf ( <urn:test:data1>
                                                 <urn:test:data2>
                                               )
                                 ] .

As you can see, the difference in this example is the owl:equivalentClass arc going from the datatype being defined to the unionOf construct, which contains also a type triple. This is missing in the original input, and the blank node is also missing. This is in contrast with the OWL to RDF mapping (I should have caught it earlier, as it is a common error and I've met it a few times before).

BlackDark commented 9 years ago

Thanks to you @ignazio1977 :+1: That was the issue. Now everything works fine so far. Should be solving some problems in ontovibe.