stuppie / WikiDataScape

A WikiData explorer for Cytoscape
6 stars 1 forks source link

Add a feature that allows you to find nodes that link an arbitrary selection of nodes #12

Open stuppie opened 8 years ago

stuppie commented 8 years ago

Add a feature that allows you to find nodes that link an arbitrary selection of nodes Example:

SELECT ?obj1Label ?propLabel ?sharedLabel ?propLabel2 ?obj2Label ?shared
WHERE
{
    values ?obj1 {wd:Q8652 wd:Q16552}
    values ?obj2 {wd:Q649}
    ?obj1 ?prop1 ?shared .
    ?shared ?prop2 ?obj2 .
    ?obj1 rdfs:label ?obj1Label FILTER (lang(?obj1Label) = 'en' )
    ?obj2 rdfs:label ?obj2Label FILTER (lang(?obj2Label) = 'en' )
    ?shared rdfs:label ?sharedLabel FILTER (lang(?sharedLabel) = 'en' )

    ?property ?ref ?prop1 .
    ?property a wikibase:Property .
    ?property rdfs:label ?propLabel .
    ?property2 ?ref2 ?prop2 .
    ?property2 a wikibase:Property .
    ?property2 rdfs:label ?propLabel2
    FILTER (lang(?propLabel) = 'en' )
    FILTER (lang(?propLabel2) = 'en' )
} limit 10

Linked by two nodes

SELECT ?leftLabel ?prop1 ?shared1Label ?prop12 ?shared2Label ?prop2 ?rightLabel ?shared1 ?shared2
WHERE
{
    values ?left {wd:Q319541 wd:Q177094 wd:Q238512}
    values ?right {wd:Q718113 wd:Q12133}
    ?left ?prop1 ?shared1 .
    FILTER NOT EXISTS {?shared1 rdf:type ?type .}
    ?shared1 ?prop12 ?shared2 .
    FILTER NOT EXISTS {?shared2 rdf:type ?type .}
    ?shared2 ?prop2 ?right .
    SERVICE wikibase:label { bd:serviceParam wikibase:language "en" }
}