简体   繁体   English

尝试通过我的Java程序查询dbpedia时发生bif:contain错误

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

the code is for querying dbpedia from java program and then displaying the result in html page 该代码用于从Java程序查询dbpedia,然后在html页面中显示结果

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. 在这里,我在这段代码中面临的问题是bif:contains显示错误,我什至尝试过然后问题仍然存在。

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 bif:contains是带前缀的名称,但您尚未为其定义前缀,因此ARQ解析器应按预期抛出错误

Unfortunately bif:contains is a Virtuoso specific extension and doesn't actually have any associated prefix so you can't define it. 不幸的是bif:contains是Virtuoso专有的扩展,实际上没有任何关联的前缀,因此您无法定义它。 However you can enclose it in < and > so that ARQ treats it like a URI and Virtuoso will still understand it ie use <bif:contains> in your query instead. 但是,您可以将其括在<>以便ARQ像对待URI一样对待它,Virtuoso仍然可以理解它,即在查询中使用<bif:contains>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM