三元组如何决定是否添加 "background" 个三元组?

How does a triplestore decide whether to add "background" triples?

我使用了几个不同的三元组,并在 RScala 中编码。我认为我在以下方面看到了一些差异:

对于是否需要添加支持词表,是否有独立于实现技术的通用规则?

R 中使用 Jena,通过 rrdf,我 通常只看我加载的:

library(rrdf)
turtle.input.string <-
  "PREFIX prefix:  <http://example.com/>
   prefix rdf:     <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
   prefix:subject rdf:type prefix:object"
jena.model <-
  fromString.rdf(rdfContent = turtle.input.string, format = "TURTLE")
model.string <- asString.rdf(jena.model, format = "TURTLE")
cat(model.string)

这给出:

@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix prefix: <http://example.com/> .
prefix:subject  a  prefix:object .

但有时 RDFRDFS 的三元组似乎在我之后添加或删除三元组时出现。 这就是 "bothers" 我最喜欢的,但我现在找不到示例。如果没有人知道我的意思,我今天晚些时候会挖掘一些东西。

当我通过 OpenRDF Sesame 库Scala 中使用 Blazegraph 时,我认为我总是得到RDFRDFSOWL "for free"

import java.util.Properties
import org.openrdf.query.QueryLanguage
import org.openrdf.rio._
import com.bigdata.journal._
import com.bigdata.rdf.sail._
object InjectionTest {
  val jnl_fn = "sparql_tests.jnl"
  def main(args: Array[String]): Unit = {
    val props = new Properties()
    props.put(Options.BUFFER_MODE, BufferMode.DiskRW)
    props.put(Options.FILE, jnl_fn)
    val sail = new BigdataSail(props)
    val repo = new BigdataSailRepository(sail)
    repo.initialize()
    val cxn = repo.getConnection()
    val resultStream = new java.io.ByteArrayOutputStream
    val resultWriter = Rio.createWriter(RDFFormat.TURTLE, resultStream)
    val ConstructString = "construct {?s ?p ?o} where {?s ?p ?o}"
    cxn.prepareGraphQuery(QueryLanguage.SPARQL, ConstructString).evaluate(resultWriter)
    var resString = resultStream.toString()
    println(resString)
  }
}

即使不添加任何三元组,construct 输出也包括这样的块:

rdfs:isDefinedBy rdfs:domain rdfs:Resource ;
    rdfs:range rdfs:Resource ;
    rdfs:subPropertyOf rdfs:isDefinedBy , rdfs:seeAlso .

Are there any general rules for whether supporting vocabularies need to be added, independent of the implementation technology?

这取决于您的 triplestore 声称支持的推理方案。对于纯 RDF 存储(无推理),根本不应添加额外的三元组。

从您展示的片段来看,您使用的 Blazegraph 存储至少启用了 RDFS 推理(可能还有部分 OWL 推理?)。请注意,这是特定于 store 的,而不是框架,因此这不是 Jena 与 Sesame 的对比:这两个框架都支持进行或不进行推理的商店。当然,如果您使用任一框架并使用它们提供的 "excluded inferred triples" 选项,则后备存储应该尊重该配置选项并且不在结果中包含此类推断的三元组。