无法推断出有趣的披萨

时间:2017-07-02 15:34:43

标签: sparql jena stardog blazegraph rdf4j

我已经将披萨本体加载到Stardog和Blazegraph,以及我撰写的一些三重奏,包括一个带有四个浇头的披萨。正如@AKSW建议的那样,我试图使浇头变得清晰。

披萨本体将一个有趣的披萨定义为披萨,至少有三个配料。我很确定我启用了OWL推理,但是没有三重商店说我的披萨很有意思

任何人都可以向我展示在任何免费提供的三元商店中启用此推理的设置,或者指出我的三元组错误吗?  特别是,我是否应该能够推断披萨实例,披萨课程或两者都“有趣”?

有趣的披萨定义:

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 已经推断我的披萨含有成分(因为它有浇头),我的披萨是一种食物,甚至我的披萨很辣,因为它有马克的墨西哥辣椒作为浇头。但它没有推断出有趣的披萨类的会员资格。

以下是我的Stardog推理设置:

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

1 个答案:

答案 0 :(得分:4)

我在Stardog 5.0上玩了一些,并获得了更多的见解:

  1. 从OWL DL视图中,本体表达足以推断出

    pizza:marksPizzaInstance rdf:type pizza:InterestingPizza .
    

    例如,可以使用Protege评估。可以使用非常酷的Protege功能计算的示例说明如下: enter image description here

    通过启用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查询返回所需的推断三元组。