0
我在我的數據集中有很多模型,我想查詢指定的模型,我在SPARQL查詢中使用了graph關鍵字,但它給了我一個空結果集 任何人都可以幫助我, ?從TDB中的數據集查詢模型
public static void SparqlForSentencesDuplicates()
{
String querystr= "PREFIX aapi:<http://rdf.alchemyapi.com/rdf/v1/s/aapi-schema#> "
+ "select ?s where {"
+"graph <RelationModel3> {"
+ "?id aapi:RelationSentence ?s } "
+"}";
Dataset ds=tdbconn.ds;
ds.begin(ReadWrite.READ);
QueryExecution qexe= QueryExecutionFactory.create(querystr, ds);
try {
ResultSet result= qexe.execSelect();
ResultSetFormatter.out(result);
}finally{
qexe.close();
ds.close();
}
}
,並在這裏,我怎麼能加載模型
public Model loadModel(String modelName, StringBuilder Builder)
{
Model model = null;
ds.begin(ReadWrite.WRITE);
try
{
//model = ds.getNamedModel(modelName);
model = ModelFactory.createDefaultModel();
model.read(new ByteArrayInputStream(Builder.toString().getBytes()), null);
ds.addNamedModel(modelName, model);
ds.commit();
}
finally
{
ds.end();
} return model;}