Hi,
check the following function:
public boolean isConceptType(String uri, String ctype) {
uri = "<" + uri + ">";
boolean results = false;
String queryString = "PREFIX rdfs:
<http://www.w3.org/2000/01/rdf-schema#>\n" +
"PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>\n" +
"ASK {\n" + " {\n " + uri + " a ?p .\n"
+ " ?p rdfs:subClassOf dbpedia-owl:" + ctype
+ " OPTION (transitive).\n" + " }\n" + "UNION\n" + " {\n "
+ uri + " a dbpedia-owl:Place .\n" + " }\n" + "}";
// --now creating query object
Query query = QueryFactory.create(queryString);
// --initializing queryExecution factory with remote service.
QueryExecution qexec = QueryExecutionFactory.sparqlService(
"http://dbpedia.org/sparql", query);
try {
results = qexec.execAsk();
} finally {
qexec.close();
}
return results;
}
In the debug mode, the value of "queryString" is something like this:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
ASK {
{
<http://dbpedia.org/resource/Iran> a ?p .
?p rdfs:subClassOf dbpedia-owl:Place OPTION (transitive).
}
UNION
{
<http://dbpedia.org/resource/Iran> a dbpedia-owl:Place .
}
}
This query is running in Virtuoso SPARQL query editor but make the following
error:
Exception in thread "main" com.hp.hpl.jena.query.QueryParseException: Lexical
error at line 6, column 48. Encountered: " " (32), after : "OPTION"
at
com.hp.hpl.jena.sparql.lang.ParserSPARQL11.perform(ParserSPARQL11.java:111)
at com.hp.hpl.jena.sparql.lang.ParserSPARQL11.parse$(ParserSPARQL11.java:53)
at com.hp.hpl.jena.sparql.lang.Parser.parse(Parser.java:37)
at com.hp.hpl.jena.query.QueryFactory.parse(QueryFactory.java:156)
at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:79)
at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:52)
at com.hp.hpl.jena.query.QueryFactory.create(QueryFactory.java:40)
at
it.uniroma1.lcl.msm2013.RunExperiments.isConceptType(RunExperiments.java:175)
at it.uniroma1.lcl.msm2013.RunExperiments.main(RunExperiments.java:286)------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_feb
_______________________________________________
Dbpedia-discussion mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dbpedia-discussion