简体   繁体   English

文字作为SPARQL三元组中的主题

[英]Literals as subject in SPARQL triples

As far as I read from the grammar of SPARQL https://www.w3.org/TR/sparql11-query/#sparqlGrammar it is allowed to have literals as the subject in a triple: 据我从SPARQL的语法https://www.w3.org/TR/sparql11-query/#sparqlGrammar所读的内容中,可以将文字作为三元组的主题:

[75]    TriplesSameSubject    ::=   VarOrTerm PropertyListNotEmpty | TriplesNode PropertyList
[106]   VarOrTerm     ::=   Var | GraphTerm
[109]   GraphTerm     ::=   iri | RDFLiteral | NumericLiteral | BooleanLiteral | BlankNode | NIL

So it would be possible to have a triple such as: 因此,可能会有一个三元组,例如:

 (3, rdfs:label, 'three')

I can handle such triples in Python's rdflib, but when I try to make a federated SPARQL query with SERVICE in Virtuoso version 06.01.3127, Virtuoso complains. 我可以在Python的rdflib中处理这样的三元组,但是当我尝试在Virtuoso 06.01.3127版中使用SERVICE进行联合SPARQL查询时,Virtuoso抱怨。 Here is an error message from my execution at a local install at http://localhost:8890/sparql 这是我在http:// localhost:8890 / sparql的本地安装中执行时的错误消息

Virtuoso 37000 Error SP031: SPARQL compiler: No one quad map pattern is suitable for GRAPH _:_::default_8_4 { 3 <http://www.w3.org/2000/01/rdf-schema#label> ?s } triple at line 8

SPARQL query:
define sql:big-data-const 0 
#output-format:text/html
define sql:signal-void-variables 1 PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>

SELECT ?s WHERE {
  SERVICE <http://127.0.0.1:5000/sparql> {
    SELECT ?s WHERE {
      3 rdfs:label ?s .
    }
  }
}

Is this a Virtuoso issue or is this a more general SPARQL/RDF issue, - or a programming error that I make? 这是Virtuoso问题,还是更普遍的SPARQL / RDF问题,还是我犯的编程错误?

Very few (I believe the current count is zero) enterprise-grade triple- or quad-stores handle "Generalized RDF", which is RDF that permits literals in the Subject position. 很少(我认为当前计数为零)企业级三层或四层存储处理“ Generalized RDF”,即允许在主题位置使用文字的RDF。 As yet, this is generally understood not to scale well, though it can be useful or interesting at small scale, such as in CWM , TimBL's Python-based Closed World Machine. 到目前为止,虽然在小规模上它可能是有用或有趣的,例如在CWM (TimBL的基于Python的封闭世界机器)中,它通常不能很好地扩展,但人们通常认为它不能很好地扩展。

Virtuoso is an enterprise-grade DBMS, handling tabular SQL data, graphical RDF data, and more. Virtuoso是企业级DBMS,可处理表格SQL数据,图形RDF数据等。 At present, and for the planned future, Virtuoso will not handle Generalized RDF. 目前,对于计划的将来,Virtuoso将不会处理Generalized RDF。

All that said, it should be noted that you're running a rather old Virtuoso, from circa July 2012. Whether you're running Commercial or Open Source , updating to a more recent build (at least 7.2.4.2 as of April 2016) is strongly recommended for a wide variety of performance and functionality reasons. 综上所述,应该注意的是,您正在运行的是2012年7月前后的Virtuoso。无论您是运行Commercial还是Open Source ,都已更新到最新版本(截至2016年4月,至少为7.2.4.2)。出于各种性能和功能方面的考虑,强烈建议使用此选项。

ObDisclaimer: OpenLink Software produces Virtuoso , and employs me. 声明: OpenLink Software生产Virtuoso ,并雇用了我。

SPARQL has always include literals as subject in the grammar even at SPARQL 1.0 - variables from one position can used in another so via variables matching literals-as-subject happens anyway. 即使在SPARQL 1.0时,SPARQL始终将文字作为语法的主题包括在内-来自某个位置的变量可以在另一位置使用,因此通过匹配文字即对象的变量无论如何都会发生。

SPARQL 1.0: SPARQL 1.0:
https://www.w3.org/TR/rdf-sparql-query/#sparqlTriplePatterns https://www.w3.org/TR/rdf-sparql-query/#sparqlTriplePatterns
SPARQL 1.1: SPARQL 1.1:
https://www.w3.org/TR/sparql11-query/#sparqlTriplePatterns https://www.w3.org/TR/sparql11-query/#sparqlTriplePatterns

Of course, they will not match RDF as stored. 当然,它们将与存储的RDF不匹配。

The rules for CONSTRUCT say "reject such triples". 构造规则说“拒绝这样的三元组”。

https://www.w3.org/TR/sparql11-query/#construct https://www.w3.org/TR/sparql11-query/#construct

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

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