AKSW / RDFUnit

An RDF Unit Testing Suite
http://RDFUnit.aksw.org
Apache License 2.0
150 stars 42 forks source link

Wrong inverse functional pattern #19

Closed LorenzBuehmann closed 9 years ago

LorenzBuehmann commented 9 years ago

The built-in pattern rutp:INVFUNCT in https://github.com/AKSW/RDFUnit/blob/master/rdfunit-core/src/main/resources/org/aksw/rdfunit/patterns.ttl is obviously wrong:

rut:sparqlWherePattern """ {   {
                                        ?a %%P1%% ?resource ;
                                           a %%T1%% .
                                        ?b %%P1%% ?resource ;
                                           a %%T1%% .
                                    } UNION {
                                        ?a %%P1%% ?resource ;
                                            rdfs:subClassOf+ %%T1%% .
                                        ?b %%P1%% ?resource ;
                                            rdfs:subClassOf+ %%T1%% .
                                    }
                                    FILTER (?a != ?b)
                                } """ ;

If you have a look at the second part of the UNION, neither ?a nor ?b is usually a class, and there is a missing triple pattern which connects the type of ?a (resp. ?b) with the rdfs:subClassOf triple pattern, i.e. it should more look like

rut:sparqlWherePattern """ {   {
                                        ?a %%P1%% ?resource ;
                                           a %%T1%% .
                                        ?b %%P1%% ?resource ;
                                           a %%T1%% .
                                    } UNION {
                                        ?a %%P1%% ?resource ; ?a a ?TA .
                                            ?TA rdfs:subClassOf+ %%T1%% .
                                        ?b %%P1%% ?resource ; ?b a ?TB .
                                            ?TB rdfs:subClassOf+ %%T1%% .
                                    }
                                    FILTER (?a != ?b)
                                } """ ;

By the way, SPARQL property paths allow for a more compact notation, using / and * like

rut:sparqlWherePattern """ {   
                                 ?a %%P1%% ?resource ;
                                 rdf:type/rdfs:subClassOf* %%T1%% .
                                ?b %%P1%% ?resource ;
                                rdf:type/rdfs:subClassOf* %%T1%% .
                                FILTER (?a != ?b)
                                } """ ;
jimkont commented 9 years ago

Thanks Lorenz,

I'll fix it & thanks for the suggestion BTW, should it be * or + ?

LorenzBuehmann commented 9 years ago

It should be * because that means 0 or n. That's why you do not need the first part of the UNION.

jimkont commented 9 years ago

But what does 0 mean in a relationship? Shouldn't there be at least one of rdfs:type / rdfs:subClassOf?

Maybe I should read again the property paths spec:-)

LorenzBuehmann commented 9 years ago

If it's 0, then it's the class itself. The combination rdf:type/rdfs:subClassOf* :A means "any subclass of :A or the class :A itself".

jimkont commented 9 years ago

I see, it's like rdfs:type/(rdfs:subClassOf*)

I thought * applied to the whole path and didn't seem right.

Thanks!