Reputation: 43
How to get the number of RDF resources (subjects) associated with a specific property?
I don't want to use the list statements iterator to count the number of unique resources because this will also count the number of statements with the same subjects but different objects. Isn't there just a method that just returns the number of unique subjects of a particular property?
StmtIterator iter = model1.listStatements();
// print out the predicate, subject and object of each statement
int u=0;
while (iter.hasNext()) {
Statement stmt = iter.nextStatement(); // get next statement
Resource subject = stmt.getSubject(); // get the subject
Property predicate = stmt.getPredicate(); // get the predicate
RDFNode object = stmt.getObject();
u++;
}
Upvotes: 0
Views: 66