Sparql rdf4j构造查询失败

Sparql rdf4j构造查询失败,sparql,rdf,wikidata,rdf4j,Sparql,Rdf,Wikidata,Rdf4j,我正在尝试使用以下代码段对Wikidata执行构造查询: construct = "CONSTRUCT { " + " ?s <http://schema.org/about> ?wikipedia ." + "} where { " + " OPTIONAL{ " + " ?wikipedia <http://schema.org/about> ?s ; &

我正在尝试使用以下代码段对Wikidata执行构造查询:

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();
            }
据我所知,Wikidata中存在一些未正确编码的URI,即存在空格。因此rdf4j解析器抱怨。有没有一种方法可以不那么严格地配置解析器

多谢各位
D063520

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

老实说,我怀疑您的查询将返回任何结果,但会导致超时
可选
是左连接,因此不可交换。秩序很重要。
可选
应位于三重模式之后。与你的相比-我也尝试过Jena,它没有语法错误。为什么你说它超时了?即使是你粘贴的链接也不会超时,但会返回一个结果?嗯,是的-但是我发布的链接在三重模式之后有
可选的
。。。您可以在web UI中对查询进行相同的尝试。我打赌你会得到一个timeout你是对的,问题是他流式传输他得到的第一个结果,然后他发送一些错误消息(timeout),这使解析器崩溃。非常感谢。
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)