首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >rdf4j构造查询失败

rdf4j构造查询失败
EN

Stack Overflow用户
提问于 2020-01-21 10:48:06
回答 1查看 189关注 0票数 1

我试图使用以下代码片段对Wikidata执行构造查询:

代码语言:javascript
运行
复制
construct = "CONSTRUCT { " +
            "   ?s <http://schema.org/about> ?wikipedia ." +
            "} where { " +
            "   OPTIONAL{ " +
            "      ?wikipedia <http://schema.org/about> ?s ; <http://schema.org/inLanguage> ?language ; <http://schema.org/isPartOf> <https://en.wikipedia.org/> . " +
            "   } "+
            "   ?s ?p1 <http://www.wikidata.org/entity/Q12136> . " +
            "}";
            repo = new SPARQLRepository("https://query.wikidata.org/sparql");
            repositoryConnection = repo.getConnection();
            query = repositoryConnection.prepareGraphQuery(construct);
            rs = query.evaluate();
            while (rs.hasNext()) {
                Statement statement = rs.next();
            }

不幸的是,这会导致一个解析错误:

代码语言:javascript
运行
复制
WARN org.eclipse.rdf4j.rio.helpers.ParseErrorLogger - [Rio error] IRI included an unencoded space: '32' (7730, -1)
org.eclipse.rdf4j.query.QueryEvaluationException: org.eclipse.rdf4j.query.QueryEvaluationException: org.eclipse.rdf4j.rio.RDFParseException: IRI included an unencoded space: '32' [line 7730]
    at org.eclipse.rdf4j.query.impl.QueueCursor.convert(QueueCursor.java:58)
    at org.eclipse.rdf4j.query.impl.QueueCursor.convert(QueueCursor.java:22)
    at org.eclipse.rdf4j.common.iteration.QueueIteration.checkException(QueueIteration.java:165)
    at org.eclipse.rdf4j.common.iteration.QueueIteration.getNextElement(QueueIteration.java:134)
    at org.eclipse.rdf4j.common.iteration.LookAheadIteration.lookAhead(LookAheadIteration.java:81)
    at org.eclipse.rdf4j.common.iteration.LookAheadIteration.hasNext(LookAheadIteration.java:49)
    at org.eclipse.rdf4j.common.iteration.IterationWrapper.hasNext(IterationWrapper.java:63)
    at eu.qanswer.mapping.mappings.informa.Refactor.main(Refactor.java:227)

据我所知,维基数据中有一些uris没有被正确编码,即有一个空格。因此,rdf4j解析器会发出抱怨。有没有一种不那么严格的配置解析器的方法?

谢谢D063520

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-01-21 23:34:09

正如您所发现的,这里的问题是您的查询在服务器端超时。您从RDF4J获得的错误消息令人困惑,但原因是服务器端点没有正确地传达存在问题:它只创建了200个HTTP响应(因此RDF4J认为一切正常,并开始处理响应体)。在运行过程中,服务器突然向响应体抛出一个错误,从而使RDF4J解析器抛出此错误。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59839409

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档