KnowWhereGraph / KWG-SHACL

This is the repository of SHACL shapes development/research for KWG.
1 stars 1 forks source link

Domain and Range Constraint #7

Closed zhurui0509 closed 2 years ago

zhurui0509 commented 2 years ago

The current shapes regarding predicate domain and range are wrong (tested in https://shacl.org/playground/) @cogan-shimizu @kbzhoulu

### Shape for class sosa:actsOnProperty
sosa-shacl:actsOnPropertyDomainConstraint
    a sh:NodeShape ;
    sh:targetSubjectsOf sh:actsOnProperty ;
    rdfs:comment "We restrict the domain of sosa:actsOnProperty to sosa:Actuation" ;
    sh:class sosa:Actuation .

sosa-shacl:actsOnPropertyRangeConstraint
    a sh:PropertyShape ;
    sh:objectSubjectsOf sh:actsOnProperty ;
    rdfs:comment "We restrict the range of sosa:actsOnProperty to sosa:ActuatableProperty" ;
    sh:class sosa:ActuatableProperty .
zhurui0509 commented 2 years ago

This version also does not work: @shirlysteph

sosa-shacl:madeActuationConstraint
    a sh:NodeShape ;
    sh:targetSubjectsOf sh:madeActuation ;

    sh:property [
        rdfs:comment "The domain of sh:madeActuation is always an instance of sosa:Actuator."@en ;
        sh:path sosa:madeActuation ;
        sh:hasValue sosa:Actuator ; 

    ] .
kbluzhou commented 2 years ago

@zhurui0509 could you please share your testing data? and what is the error message?

zhurui0509 commented 2 years ago

I just create a toy sample to test these shapes in https://shacl.org/playground/. None of the property shapes works.

One example:

shape:

sosa-shacl:madeByActuatorDomainConstraint
    a sh:NodeShape ;
    sh:targetSubjectsOf sosa:madeByActuator ;
    rdfs:comment "We restrict the domain of sosa:madeByActuator to sosa:Actuation" ;
    sh:class sosa:Actuation .

data:

ex:obs a sosa:Observation . 
ex:obs sosa:madeByActuator sosa:abc .   

The data should violate the shape. But nothing returned from the validation.

zhurui0509 commented 2 years ago

Meanwhile, I also don't have good ideas of how to write those domain and range in SHACL.

@ling-cai and I had discussed about it and we agreed that sh:targetSubjectsOf and sh:targetObjectsOf might not work (based on the example showed in SHACL W3C document).

Probably, we need SHACL-SPARQL.

Btw, aren't we more interested in scoped domain and range, which is more complicated in SHACL?

cogan-shimizu commented 2 years ago

@zhurui0509 unfortunately, it looks like you did not do your testing on a fully pulled repository.

cogan-shimizu commented 2 years ago

Actually, from what I can tell, you reverted these shapes back into node shapes, why did you do that?

cogan-shimizu commented 2 years ago

Unfortunately, it looks like you accidentally overwrote many changes. For example, https://github.com/KnowWhereGraph/KWG-SHACL/issues/7#issuecomment-923650436 this version came from your typo fix commit. Technically, the previous version would not have worked either, but this one is the original one that we found to be incorrect in an earlier discussion on slack.