简体   繁体   English

从生产者-消费者 OWL model 实现和检索信息

[英]Realizing and Retrieving information from a producer-consumer OWL model

I have the following scenario modelled in OWL:我在 OWL 中建模了以下场景:

Producer ----producesResource---> Resource <------consumesResource ---- Consumer Producer ----producesResource---> Resource <------consumesResource ---- Consumer

Producer , Resource and Consumer are OWL Classes, while producesResource and consumesResource are object properties. ProducerResourceConsumer是 OWL 类, producesResourceconsumesResource是 object 属性。 The scenario is quite intuitive in that that each producer produces one or more resources that is consumed by one or more consumers.该场景非常直观,因为每个生产者生产一个或多个资源,由一个或多个消费者消耗。 Conversely, each consumer can consume one or more resources.相反,每个消费者可以消耗一个或多个资源。 The ontology is populated with instances / individuals accordingly.本体相应地填充有实例/个体。

I would like to check if there exists a resource that is consumed by a consumer that is not produced by a Producer.我想检查是否存在不是由生产者生产的消费者消费的资源。 What is an elegant way to get this information via a:什么是通过以下方式获取此信息的优雅方式:

  1. Query in SPARQL在 SPARQL 中查询
  2. SHACL Shapes graph (if possible). SHACL 形状图(如果可能)。

Negations are possible in SPARQL using the NOT BOUND filter or more easily in SPARQL 1.1 using MINUS:在 SPARQL 中可以使用 NOT BOUND 过滤器进行否定,或者在 SPARQL 1.1 中使用 MINUS 更容易:

SELECT ?resource WHERE
{
  ?resource a :Resource.

  ?consumer a :Consumer;
    ?consumer :consumesResource ?resource.

 MINUS {?producer a :Producer; :producesResource ?resource.}
}

You can also use ASK to get a boolean result but SELECT allows easier debugging to verify if your query is working correctly.您还可以使用ASK获得 boolean 结果,但SELECT允许更轻松地调试以验证您的查询是否正常工作。

As SHACL allows integrating SPARQL queries, this answers your second question too but in that case it is easier to just use the SPARQL query on its own.由于 SHACL 允许集成 SPARQL 查询,这也回答了您的第二个问题,但在这种情况下,单独使用 SPARQL 查询会更容易。

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

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