Reputation: 391
I want to count assertions of a specific relationship in OWL file. if following is my whole Ontology:-
<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>
then sparql query should give me something like:-
SynonymOf = 4 (i.e 4 assertions for <SynonymOf> relation
I intend to run the query on jena fuzeki.
Upvotes: 1
Views: 487
Reputation: 3301
A straightforward way would be:
PREFIX : <http://example.com#>
SELECT (count(?o) as ?count)
WHERE {
?s :SynonymOf ?o
}
However, for the binding to be assigned to specific objects, you might want to consider using Group By
:
PREFIX : <http://example.com#>
SELECT ?s (count(?o) as ?count)
WHERE {
?s :SynonymOf ?o
}
GROUP BY ?s
Upvotes: 3