3

我在两个不同的引擎中尝试了一个 SPARQL 查询:

  1. Protege 4.3 - SPARQL 查询选项卡
  2. 耶拿 2.11.0

虽然查询相同,但这两个工具返回的结果不同。

我尝试了DESCRIBE如下查询:

DESCRIBE ?x
WHERE { ?x :someproperty "somevalue"}

protege 的结果给了我?x作为主语/宾语的元组;而来自耶拿的那些?x只是作为主题。

我的问题是:

  1. SPARQL 的语法是否统一?
  2. 如果我想DESCRIBE在 protege 工作,我应该在耶拿做什么?
4

1 回答 1

3

To answer your first question yes the SPARQL syntax is uniform since you've used the same query in both tools. However what I think you are actually asking is should the results for the two tools be different or not? i.e. are the semantics of SPARQL uniform

In the case of DESCRIBE then yes the results are explicitly allowed to be different by the SPARQL specification i.e. no the semantics of SPARQL are not uniform but this is only in the case of DESCRIBE.

See Section 16.4 DESCRIBE (Informative) of the SPARQL Specification which states the following:

The query pattern is used to create a result set. The DESCRIBE form takes each of the resources identified in a solution, together with any resources directly named by IRI, and assembles a single RDF graph by taking a "description" which can come from any information available including the target RDF Dataset. The description is determined by the query service

The important part of this is the last couple of sentences that say the description is determined by the query service. This means that both Protege's and Jena's answers are correct since they are allowed to choose how they form the description.

Changing Jena DESCRIBE handling

To answer the second part of your question you can change how Jena processes DESCRIBE queries by implementing a custom DescribeHandler and an associated DescribeHandlerFactory. You then need to register your factory like so:

DescribeHandlerRegistry.get().set(new YourDescribeHandlerFactory());
于 2014-01-22T03:14:42.660 回答