特定组实例的三元组数量?
Number of triples of specific group instances?
我在 SPARQLing dbpedia 中发现了另一个问题。我正在尝试获取特定 class 实例组的三元组数量。
class 政治家的三元组数:
SELECT * WHERE {?s ?p ?o FILTER (?s = dbo:Politician OR ?o = dbo:Politician)}
但是特定政客群体的所有三元组的汇总数呢?例如德国政客的三元组数。怎么可能得到?
感谢您的帮助!
修改后的答案
这将 get the count of entities who are described as being Politicians from Germany —
SELECT COUNT(*)
{ ?s a dbo:Politician .
?s dbo:nationality dbr:Germany .
}
SELECT COUNT(*)
{ ?s a dbo:Politician .
?s dbo:nationality dbr:Germany .
?s ?p ?o .
}
SELECT COUNT(*)
{ { ?s a dbo:Politician .
?s dbo:nationality dbr:Germany .
?s ?p ?o .
}
UNION
{ ?o a dbo:Politician .
?o dbo:nationality dbr:Germany .
?s ?p ?o .
}
}
原回答
我 认为 你目前的目标是 this,它将所有带有 dbo:Politician
的三元组计算为主题或对象(当前为 41105,没有超时),但请注意,此查询不计算“作为政客的实体”,这是(我认为)您真正想要的!
SELECT ( COUNT ( * ) AS ?NumberOfTriples )
WHERE
{ { dbo:Politician ?p ?o }
UNION
{ ?s ?p dbo:Politician }
}
如果您想计算“政客实体”的数量(即 rdf:type dbo:Politician
)(目前为 41078),您需要一个不同的查询,例如 this --
SELECT ( COUNT ( DISTINCT ?s ) AS ?NumberOfPoliticians )
WHERE
{ ?s rdf:type dbo:Politician }
这应该通过看一下 the { dbo:Politician ?p ?o }
triples --
来澄清
SELECT *
WHERE
{ dbo:Politician ?p ?o }
我在 SPARQLing dbpedia 中发现了另一个问题。我正在尝试获取特定 class 实例组的三元组数量。
class 政治家的三元组数:
SELECT * WHERE {?s ?p ?o FILTER (?s = dbo:Politician OR ?o = dbo:Politician)}
但是特定政客群体的所有三元组的汇总数呢?例如德国政客的三元组数。怎么可能得到?
感谢您的帮助!
修改后的答案
这将 get the count of entities who are described as being Politicians from Germany —
SELECT COUNT(*)
{ ?s a dbo:Politician .
?s dbo:nationality dbr:Germany .
}
SELECT COUNT(*)
{ ?s a dbo:Politician .
?s dbo:nationality dbr:Germany .
?s ?p ?o .
}
SELECT COUNT(*)
{ { ?s a dbo:Politician .
?s dbo:nationality dbr:Germany .
?s ?p ?o .
}
UNION
{ ?o a dbo:Politician .
?o dbo:nationality dbr:Germany .
?s ?p ?o .
}
}
原回答
我 认为 你目前的目标是 this,它将所有带有 dbo:Politician
的三元组计算为主题或对象(当前为 41105,没有超时),但请注意,此查询不计算“作为政客的实体”,这是(我认为)您真正想要的!
SELECT ( COUNT ( * ) AS ?NumberOfTriples )
WHERE
{ { dbo:Politician ?p ?o }
UNION
{ ?s ?p dbo:Politician }
}
如果您想计算“政客实体”的数量(即 rdf:type dbo:Politician
)(目前为 41078),您需要一个不同的查询,例如 this --
SELECT ( COUNT ( DISTINCT ?s ) AS ?NumberOfPoliticians )
WHERE
{ ?s rdf:type dbo:Politician }
这应该通过看一下 the { dbo:Politician ?p ?o }
triples --
SELECT *
WHERE
{ dbo:Politician ?p ?o }