shexSpec / shex

ShEx language issues, including new features for e.g. ShEx2.1
24 stars 8 forks source link

Support for circular references that compare their values #85

Open labra opened 6 years ago

labra commented 6 years ago

This issue wants to express a recursive model where the values refer to themselves.

The example is between a person that owns a dog and a dog that likes a person, but the condition is that the value owned by a person must like that person.

To express that condition, I think we need to solve this issue before to be able to compare values.

A possible syntax could be:

PREFIX :       <http://example.org/>

:Person { 
 $<Dog> :owns  @:Dog;
$this = $<Dog>/likes
}

:Dog {
  :likes @:Person
}

in this way the following example:

@prefix :      <http://example.org/> .

:Bob    :owns   :Fido .    # Fails because :Fido doesn't like :Bob
:Fido   :likes  :Jane .

:Jane   :owns   :Spot .   # Conforms, because Spot likes :Jane
:Spot   :likes  :Jane .
balhoff commented 4 years ago

I just want to express my support for this feature addition. I think it's what we need in the OBO ShEx file to state that a term should not have a synonym the same as its label, but I think our requirement would be a negation of this (we basically want disjoint properties). For example:

# Should fail because GO:1234 has the same text as a label and as exact synonym
GO:1234    rdfs:label                "nucleus" . 
GO:1234    oboInOwl:hasExactSynonym  "nucleus" .

Currently we're using SPARQL like this to query for these issues:

PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX oboInOwl: <http://www.geneontology.org/formats/oboInOwl#>

SELECT ?c ?oneSynonym ?anotherSynonym ?syn
WHERE {

    VALUES ?oneSynonym {
        rdfs:label
        oboInOwl:hasSynonym
        oboInOwl:hasExactSynonym
        oboInOwl:hasNarrowSynonym
        oboInOwl:hasBroadSynonym
        oboInOwl:hasRelatedSynonym
    }

    VALUES ?anotherSynonym {
        rdfs:label
        oboInOwl:hasSynonym
        oboInOwl:hasExactSynonym
        oboInOwl:hasNarrowSynonym
        oboInOwl:hasBroadSynonym
        oboInOwl:hasRelatedSynonym
    }

    ?c ?oneSynonym ?syn .
    ?c ?anotherSynonym ?syn .

    FILTER NOT EXISTS {
        ?c owl:deprecated true .
    }
    FILTER (STR(?anotherSynonym) < STR(?oneSynonym))
}