我想计算OWL文件中特定关系的断言。如果以下是我的整个本体论: -
<owl:NamedIndividual rdf:about="file:/C:/myOnt.owl#comfort">
<SynonymOf rdf:resource="file:/C:/myOnt.owl#impunity"/>
<SynonymOf rdf:resource="file:/C:/myOnt.owl#sooth"/>
<SynonymOf rdf:resource="file:/C:/myOnt.owl#ease"/>
</owl:NamedIndividual>
<owl:NamedIndividual rdf:about="file:/C:/myOnt.owl#population">
<SynonymOf rdf:resource="file:/C:/myOnt.owl#habitation"/>
</owl:NamedIndividual>
那么sparql查询应该给我一些类似的东西: -
SynonymOf = 4 (i.e 4 assertions for <SynonymOf> relation
我打算在jena fuzeki上运行查询。
答案 0 :(得分:3)
一种直截了当的方式是:
PREFIX : <http://example.com#>
SELECT (count(?o) as ?count)
WHERE {
?s :SynonymOf ?o
}
但是,对于要分配给特定对象的绑定,您可能需要考虑使用Group By
:
PREFIX : <http://example.com#>
SELECT ?s (count(?o) as ?count)
WHERE {
?s :SynonymOf ?o
}
GROUP BY ?s
答案 1 :(得分:0)
SELECT (COUNT(?s) as ?SynonymOf)
WHERE {
GRAPH ?g {?s SynonymOf ?o }
}