How to assert inverse triples via SHACL (provided that they do not yet exist?)

126 views Asked by At

I have an ontology in which each thematic role (e.g., has-agent) is represented via an object property. Furthermore, the inverse property is always defined (e.g., is-agent-of).

I want to assert in the ontology all inverse triples via SHACL rules PROVIDED THAT THEY DO NOT ALREADY EXIST.

Thus, I wrote the following rule:

:assertInverseTriplesOnHasAgent rdf:type sh:NodeShape;
    sh:rule [rdf:type sh:TripleRule;
        sh:condition
        [
            sh:not[
                sh:property[
                    sh:path (TBox:has-agent TBox:is-agent-of);
                    sh:minCount 1;
                    sh:equals sh:this
                ]
            ]
        ];
        sh:subject [sh:path TBox:has-agent];
        sh:predicate TBox:is-agent-of;
        sh:object sh:this
    ];
    sh:targetSubjectsOf TBox:has-agent.

But it does not work: it asserts the inverse triples even when they already exist (and it shouldn't).

I suspect that "sh:equals sh:this" is not correct, i.e., that "sh:this" cannot be used within sh:property. On the other hand, "sh:minCount 1;" alone does not work because someone can be is-agent-of more than one action.

Can anyone help me? Thanks

0

There are 0 answers