【问题标题】:Can MarkLogic use inference over embedded triples?MarkLogic 可以对嵌入式三元组进行推理吗?
【发布时间】:2015-05-08 08:41:42
【问题描述】:

当使用 sem:sparql 针对选定的一组商店查询三元组时,MarkLogic 是否会应用推理?

【问题讨论】:

标签: rdf marklogic


【解决方案1】:

如果您已经在三元组之间建立了一些关系并尝试使用规则集获取结果,那么 Marklogic 肯定会在执行搜索时应用推理。

例如,我创建了以下三元组

 PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
 PREFIX prod: <http://www.example.com/products/>
 PREFIX ex: <http://www.example.com/>

 INSERT DATA
 {

   prod:1001 rdf:type ex:Apple;

   prod:1002 rdf:type ex:Fruit;

 }

现在,如果您搜索所有类型为 apple 的主题,它只会给您 prod:1002

现在将它们之间的关系建立为

 PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
 PREFIX ex: <http://www.example.com/>

 INSERT DATA
 {

   ex:Apple rdfs:subClassOf ex:Fruit .

 }

并将数据库的默认规则集设置为 subClassOf.rules,然后运行相同的查询

 PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
 PREFIX ex: <http://www.example.com/>

 SELECT ?product
 WHERE
 {
  ?product rdf:type ex:Fruit 
 }

现在它会同时返回 prod:1001 和 prod:1002

还可以访问 marklogic 文档以了解更多详细信息,该文档对推理有很好的描述。 https://developer.marklogic.com/features/semantics/inference-examples

【讨论】:

    【解决方案2】:

    Alex,看看Choosing Rulesets for Queries。您将在那里看到一个示例,其中将 SPARQL 查询应用于三元组存储,该存储是通过将两组推理规则应用于一组三元组而产生的。如果您稍微修改该示例,它会显示一个 SPARQL 查询,该查询应用于对三元组索引中的所有三元组(包括嵌入式三元组)运行推理。

    xquery version "1.0-ml";
    import module namespace sem = "http://marklogic.com/semantics" 
      at "/MarkLogic/semantics.xqy";
    
    PREFIX skos: <http://www.w3.org/2004/02/skos/core#Concept/>
    
    sem:sparql("select * { ?c a skos:Concept; rdfs:label ?l }",(),(),
      sem:ruleset-store(
        ("subClassOf.rules", "subPropertyOf.rules"),
        sem:store()
      )
    )
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-09-10
      • 1970-01-01
      • 2021-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多