2015-08-03 22 views
0

如何獲取與特定屬性關聯的RDF資源(主題)的數量?具有特定屬性的RDF資源數

我不想使用列表語句迭代器來計算唯一資源的數量,因爲這也會計算具有相同主題但不同對象的語句的數量。是不是隻有一種方法可以返回特定屬性的唯一主題數量?

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++; 
} 

回答