我想在 Sparql 中进行以下查询:“涉及巴拉克奥巴马和其他两个与伊利诺伊州有某种联系的人的社会三合会。” 社会三合会是由三个人组成的一组,每对之间都有联系。
# Find social triads involving Barack Obama and two other people who
# have some connection to the state of Illinois. A social triad is a
# group of three people where there is a link between every pair.
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbpr: <http://dbpedia.org/resource/>
PREFIX dbpo: <http://dbpedia.org/ontology/>
PREFIX dbpprop: <http://dbpedia.org/property/>
PREFIX dbpedia: <http://dbpedia.org/resource/>
PREFIX owl: <http://www.w3.org/2002/07/owl#>
SELECT distinct ?P1 ?P2
WHERE {
?P1 a dbpo:Person.
?P2 a dbpo:Person.
?P1 dbpprop:state dbpr:Illinois.
?P2 dbpprop:state dbpr:Illinois.
?prop a rdf:Property.
{?P1 ?prop ?P2} UNION {?P2 ?prop ?P1}.
{dbpedia:Barack_Obama ?prop ?P1} UNION {?P1 ?prop dbpedia:Barack_Obama}.
{dbpedia:Barack_Obama ?prop ?P2} UNION {?P2 ?prop dbpedia:Barack_Obama}.
}
但是我没有得到任何结果。我怎样才能让它工作?此外,我希望 ?P1 和 ?P2 是不同的人。这怎么可能?