query-1b38a47acb4853ab2132f14b5e1fd93c
List of inverse properties. SELECT ?a ?aLabel ?b ?bLabel ?type WHERE { { # non-complementry properties ?a wdt:P1696 ?b . MINUS { ?b wdt:P1696 ?a . } BIND("non-complementary" AS ?type) } UNION { # complementary properties (halved set) ?a wdt:P1696 ?b . ?b wdt:P1696 ?a . MINUS { ?a wdt:P1696 ?a . } FILTER (STR(?a) < STR(?b)) BIND("complementary" AS ?type) } UNION { # complementary - inverse is same ?a wdt:P1696 ?a . ?a wdt:P1696 ?b . BIND("inverse is same" AS ?type) } SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } } ORDER BY ?type ?aLabel ?bLabel
Use at
- https://query.wikidata.org/sparql
PREFIX wikibase: <http://wikiba.se/ontology#>
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX bd: <http://www.bigdata.com/rdf#>
#List of inverse properties.
SELECT ?a ?aLabel ?b ?bLabel ?type
WHERE {
{
# non-complementry properties
?a wdt:P1696 ?b .
MINUS { ?b wdt:P1696 ?a . }
BIND("non-complementary" AS ?type)
} UNION {
# complementary properties (halved set)
?a wdt:P1696 ?b .
?b wdt:P1696 ?a .
MINUS { ?a wdt:P1696 ?a . }
FILTER (STR(?a) < STR(?b))
BIND("complementary" AS ?type)
} UNION {
# complementary - inverse is same
?a wdt:P1696 ?a .
?a wdt:P1696 ?b .
BIND("inverse is same" AS ?type)
}
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
}
ORDER BY ?type ?aLabel ?bLabel
Query found at
graph TD
classDef projected fill:lightgreen;
classDef literal fill:orange;
classDef iri fill:yellow;
v4("?a"):::projected
v2("?aLabel"):::projected
v5("?b"):::projected
v3("?bLabel"):::projected
v6("?type"):::projected
a1((" "))
a2((" "))
c3(["bd:serviceParam"]):::iri
c5(["en"]):::literal
subgraph union0[" Union "]
subgraph union0l[" "]
style union0l fill:#abf,stroke-dasharray: 3 3;
subgraph union1[" Union "]
subgraph union1l[" "]
style union1l fill:#abf,stroke-dasharray: 3 3;
f0[["sameterm(?a,)"]]
f0 --> v4
f0 --> a2
v4 --"wdt:P1696"--> a2
v4 --"wdt:P1696"--> v5
bind1[/"'inverse is same'"/]
bind1 --as--o v6
end
subgraph union1r[" "]
style union1r fill:#abf,stroke-dasharray: 3 3;
f2[["str(?a) < str(?b)"]]
f2 --> v4
f2 --> v5
v4 --"wdt:P1696"--> v5
v5 --"wdt:P1696"--> v4
subgraph minus3["MINUS"]
style minus3 stroke-width:6px,fill:pink,stroke:red;
f4[["sameterm(?a,)"]]
f4 --> v4
f4 --> a1
v4 --"wdt:P1696"--> a1
end
bind5[/"'complementary'"/]
bind5 --as--o v6
end
union1r <== or ==> union1l
end
end
subgraph union0r[" "]
style union0r fill:#abf,stroke-dasharray: 3 3;
v4 --"wdt:P1696"--> v5
subgraph minus6["MINUS"]
style minus6 stroke-width:6px,fill:pink,stroke:red;
v5 --"wdt:P1696"--> v4
end
bind7[/"'non-complementary'"/]
bind7 --as--o v6
end
union0r <== or ==> union0l
end
subgraph s1["http://wikiba.se/ontology#label"]
style s1 stroke-width:4px;
c3 --"wikibase:language"--> c5
end