Overview
I had the opportunity to count co-occurrence frequencies for RDF triples, so here are my notes. Following the previous article, I will again use the Japan Search RDF store as an example.
Example 1
The following query counts the number of triples among sword-type instances that share a common creator (schema:creator). The filter avoids counting identical instances and prevents duplicate counting.
select (count(*) as ?count) where {
?entity1 a type:刀剣;
schema:creator ?value .
?entity2 a type:刀剣;
schema:creator ?value .
FILTER(?entity1 != ?entity2 && ?entity1 < ?entity2)
}
Example 2
Let’s display the specific triples.
select ?entity1 ?entity2 ?value where {
?entity1 a type:刀剣;
schema:creator ?value .
?entity2 a type:刀剣;
schema:creator ?value .
FILTER(?entity1 != ?entity2 && ?entity1 < ?entity2)
}
This allows us to retrieve a list of sword-type instances that share common values.

Summary
There may be some inaccuracies, but I hope this serves as a useful reference.