Matcher rule
same-active-ingredient-key-joined-first
Two records of one kind match when their current versions give two different allergen codes that one version of a product ingredient table maps to one ingredient. A product of several ingredients maps to the concept of exactly those, never to one of them, so it matches no record of only one. Each ordered pair is a row, with the version whose rows joined it; a graph that is not a version of a product ingredient table is never read for rows.
The query
PREFIX cascade: <https://ns.cascadeprotocol.org/cascade#>
PREFIX obo: <http://purl.obolibrary.org/obo/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
PREFIX pav: <http://purl.org/pav/>
PREFIX prov: <http://www.w3.org/ns/prov#>
SELECT DISTINCT ?record ?other ?origin
WHERE {
?origin prov:specializationOf/cascade:tableKind cascade:ProductIngredients .
?record pav:hasCurrentVersion ?version .
?version cascade:allergenCode ?code .
GRAPH ?origin {
?row owl:annotatedSource ?code ; owl:annotatedProperty obo:RO_0002248 ; owl:annotatedTarget ?ingredient .
?otherRow owl:annotatedTarget ?ingredient ; owl:annotatedProperty obo:RO_0002248 ; owl:annotatedSource ?otherCode .
}
FILTER (!sameTerm(?code, ?otherCode))
?otherVersion cascade:allergenCode ?otherCode .
?other pav:hasCurrentVersion ?otherVersion .
?record cascade:recordKind ?kind .
?other cascade:recordKind ?otherKind .
FILTER (?record != ?other && sameTerm(?kind, ?otherKind))
}
Terms it reads
cascade:ProductIngredients · cascade:allergenCode · cascade:recordKind · obo:RO_0002248 · owl:annotatedProperty · owl:annotatedSource · owl:annotatedTarget · pav:hasCurrentVersion · prov:specializationOf
Rules and decision notes that name it
- M4d. Each version of the rule list names, for each of its rules from R1 to R21, the query that rule's row runs runtime/matcher.feature
queries/matcher/same-active-ingredient-key-joined-first.rq on GitHub ↗