bif:contain error occurs when try to query dbpedia through my java program

两盒软妹~` 提交于 2019-12-13 08:27:25

问题


the code is for querying dbpedia from java program and then displaying the result in html page

package jenaamem;

import com.hp.hpl.jena.query.Query;
import com.hp.hpl.jena.query.QueryExecution;
import com.hp.hpl.jena.query.QueryExecutionFactory;
import com.hp.hpl.jena.query.QueryFactory;
import com.hp.hpl.jena.query.ResultSet;
import com.hp.hpl.jena.query.ResultSetFormatter;
import com.hp.hpl.jena.sparql.engine.http.QueryEngineHTTP;

public class db2
{
static public void main(String...argv)
{
    try {
        String queryStr = "SELECT * WHERE{ ?s ?p ?o . ?o bif:contains' barack and obama and america' OPTION (score ?sc) } ORDER BY DESC (?sc) LIMIT 10 ";
        Query query = QueryFactory.create(queryStr);

        // Remote execution.
        QueryExecution qexec =   QueryExecutionFactory.sparqlService("http://dbpedia.org/sparql", query);
        // Set the DBpedia specific timeout.
        ((QueryEngineHTTP)qexec).addParam("timeout", "10000") ;

        // Execute.
        ResultSet rs = qexec.execSelect();
        ResultSetFormatter.out(System.out, rs, query);
        qexec.close();
    } catch (Exception e) {
    }


}

}

here the problem i am facing in this code is that bif:contains is showing error, i even tried then also my problem continues.


回答1:


bif:contains is a prefixed name but you haven't defined a prefix for it so the ARQ parser throws an error as it should

Unfortunately bif:contains is a Virtuoso specific extension and doesn't actually have any associated prefix so you can't define it. However you can enclose it in < and > so that ARQ treats it like a URI and Virtuoso will still understand it i.e. use <bif:contains> in your query instead.



来源:https://stackoverflow.com/questions/15876916/bifcontain-error-occurs-when-try-to-query-dbpedia-through-my-java-program

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!