无法推断出有趣的披萨

Can't infer an interesting pizza

我已经将披萨 ontology 加载到 Stardog 和 Blazegraph 中,连同我编写的一些三元组,包括一个有四种浇头的披萨。正如@AKSW 所建议的,我已尝试使浇头与众不同。

比萨饼 ontology 将有趣的比萨饼定义为具有至少三种配料的比萨饼。我很确定我启用了 OWL 推理,但是 triplestore 都没有说我的披萨很有趣

任何人都可以向我展示在任何免费提供的三元组中启用此推理的设置,或者指出我的三元组做错了什么吗? 特别是,我是否应该能够推断披萨实例、披萨 classes 或两者都是 "interesting"?

有趣的披萨定义:

pizza:InterestingPizza rdf:type owl:Class ;
    owl:equivalentClass [ owl:intersectionOf ( pizza:Pizza
            [ rdf:type owl:Restriction ;
                owl:onProperty pizza:hasTopping ;
                owl:minCardinality "3"^^xsd:nonNegativeInteger
            ]
        ) ;
        rdf:type owl:Class
    ] ;
        rdfs:label "PizzaInteressante"@pt .

我的额外三元组:

@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix pizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#> .

<http://www.co-ode.org/ontologies/pizza/pizza.owl#marksPizzaClass>
  a owl:Class ;
  owl:equivalentClass [
    a owl:Restriction ;
    owl:onProperty <http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping> ;
    owl:someValuesFrom <http://www.co-ode.org/ontologies/pizza/pizza.owl#CaperTopping>
  ], [
    a owl:Restriction ;
    owl:onProperty <http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping> ;
    owl:someValuesFrom <http://www.co-ode.org/ontologies/pizza/pizza.owl#JalapenoPepperTopping>
  ], [
    a owl:Restriction ;
    owl:onProperty <http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping> ;
    owl:someValuesFrom <http://www.co-ode.org/ontologies/pizza/pizza.owl#LeekTopping>
  ], [
    a owl:Restriction ;
    owl:onProperty <http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping> ;
    owl:someValuesFrom <http://www.co-ode.org/ontologies/pizza/pizza.owl#MozzarellaTopping>
  ], [
    a owl:Restriction ;
    owl:onProperty <http://www.co-ode.org/ontologies/pizza/pizza.owl#hasTopping> ;
    owl:someValuesFrom <http://www.co-ode.org/ontologies/pizza/pizza.owl#PineKernels>
  ] ;
  rdfs:subClassOf <http://www.co-ode.org/ontologies/pizza/pizza.owl#Pizza> ;
  rdfs:label "mark's pizza class" .

<http://www.co-ode.org/ontologies/pizza/pizza.owl#marksPizzaClassMember>
  a owl:NamedIndividual, <http://www.co-ode.org/ontologies/pizza/pizza.owl#marksPizzaClass> ;
  rdfs:label "a member of the mark's pizza class" .

<http://www.co-ode.org/ontologies/pizza/pizza.owl#marksPizzaInstance>
  a owl:NamedIndividual, <http://www.co-ode.org/ontologies/pizza/pizza.owl#Pizza> ;
  pizza:hasTopping pizza:marksPeppers, pizza:topping1, pizza:topping2, pizza:topping3, pizza:topping4 ;
  rdfs:label "mark's pizza instance" .

pizza:marksPeppers
  a owl:NamedIndividual, pizza:JalapenoPepperTopping ;
  rdfs:label "mark's special spicy jalapenos" .

pizza:topping1
  a owl:NamedIndividual, pizza:MozzarellaTopping ;
  rdfs:label "mark's semi secret topping one" .

pizza:topping2
  a owl:NamedIndividual, pizza:PineKernels ;
  rdfs:label "mark's semi secret topping two" .

pizza:topping3
  a owl:NamedIndividual, pizza:CaperTopping ;
  rdfs:label "mark's semi secret topping three" .

pizza:topping4
  a owl:NamedIndividual, pizza:LeekTopping ;
  rdfs:label "mark's semi secret topping four" .

[]
  a owl:AllDifferent ;
  owl:distinctMembers (
   pizza:marksPeppers
   pizza:topping1
   pizza:topping2
   pizza:topping3
   pizza:topping4
 ) .

查询有关具有五种不同浇头的披萨实例的任何知识:

prefix pizza: <http://www.co-ode.org/ontologies/pizza/pizza.owl#>
select *
where
{ pizza:marksPizzaInstance ?p ?o }

来自 Stardog 的结果 (我手动用带前缀的 URI 替换了完整的 URI):

+---------------------+----------------------------+
|          p          |             o              |
+---------------------+----------------------------+
| pizza:hasIngredient | pizza:topping1             |
| pizza:hasIngredient | pizza:topping2             |
| pizza:hasIngredient | pizza:topping3             |
| pizza:hasIngredient | pizza:topping4             |
| pizza:hasIngredient | pizza:marksPeppers         |
| pizza:hasTopping    | pizza:topping1             |
| pizza:hasTopping    | pizza:topping2             |
| pizza:hasTopping    | pizza:topping3             |
| pizza:hasTopping    | pizza:topping4             |
| pizza:hasTopping    | pizza:marksPeppers         |
| rdfs:label          | mark's pizza instance      |
| rdf:type            | owl:Thing                  |
| rdf:type            | pizza:DomainConcept        |
| rdf:type            | pizza:Food                 |
| rdf:type            | pizza:Pizza                |
| rdf:type            | pizza:SpicyPizza           |
| rdf:type            | pizza:SpicyPizzaEquivalent |
| rdf:type            | pizza:CheeseyPizza         |
| rdf:type            | pizza:marksPizzaClass      |
+---------------------+----------------------------+

Stardog 已经 推断我的披萨有配料(因为它有浇头),我的披萨是一种食物,甚至我的披萨是辣的,因为它有马克的墨西哥胡椒作为浇头。但它还没有推断出有趣的披萨 class.

中的成员资格

这是我的 Stardog 推理设置:

Reasoning type: SL
Reasoning approximate: ON 
SameAs reasoning: FULL
TBox named graph: *

我玩了一下 Stardog 5.0 并获得了更多见解:

  1. 从 OWL DL 视图来看,ontology 的表现力足以推断出

    pizza:marksPizzaInstance rdf:type pizza:InterestingPizza .
    

    这可以用 Protege 来评估。可以使用非常酷的 Protege 功能计算的示例解释是:

    我可以通过启用 DL 推理在 Stardog 中实现同样的效果:

    bin/stardog-admin db offline pizzaDB
    bin/stardog-admin metadata set -o reasoning.type=DL pizzaDB
    bin/stardog-admin db online pizzaDB
    

    结果:

    +-------------------+-------------------------+
    |         p         |            o            |
    +-------------------+-------------------------+
    |  pizza:hasTopping |  pizza:topping1         |
    |  pizza:hasTopping |  pizza:topping2         |
    |  pizza:hasTopping |  pizza:marksPeppers     |
    |  pizza:hasTopping |  pizza:topping3         |
    |  pizza:hasTopping |  pizza:topping4         |
    |  rdf:type         |  pizza:Pizza            |
    |  rdf:type         |  owl:Thing              |
    |  rdf:type         |  pizza:InterestingPizza |
    +-------------------+-------------------------+
    
  2. 对于 Stardog 配置文件 SL 它不起作用,因为公理不在配置文件中。当查看报告所有被忽略的公理的 Stardog 日志文件时,可以识别这一点:

    WARN  2017-07-03 09:54:51,219 [XNIO-1 task-6] com.clarkparsia.blackout.ProfileFilterBase:apply(39): 
    Not a valid SL axiom: 
    EquivalentClasses(pizza:InterestingPizza, and(pizza:Pizza, min(pizza:hasTopping,3,owl:Thing))) 
    

    然后我尝试添加一个 SWRL 规则,因为 SL 配置文件支持它:

    Pizza(?x), hasTopping(?x, ?y1), hasTopping(?x, ?y2), hasTopping(?x, ?y3),  
    DifferentFrom (?y1, ?y2),  DifferentFrom (?y1, ?y3),  DifferentFrom (?y2, ?y3) 
    -> InterestingPizza(?x)
    

    令人惊讶的是,这也不起作用。我想我错过了一些重要的事情,我仍在调查为什么这不起作用。

    最后,我尝试了 Stardog 规则而不是 SWRL,它有一个非常简洁的语法接近 SPARQL(基本上使用 BGP):

    [] a rule:SPARQLRule ;
     rule:content """
        PREFIX :<http://www.co-ode.org/ontologies/pizza/pizza.owl#>
          IF {
                ?p a :Pizza ;
                   :hasTopping ?t1 , ?t2, ?t3
                FILTER(?t1 != ?t2 && ?t1 != ?t3 && ?t2 != ?t3)
             }
          THEN {
                ?p a :InterestingPizza
              }""" .
    

    这按预期工作,SPARQL 查询 returns 所需的推断三元组。