2

我已经将披萨本体加载到 Stardog 和 Blazegraph 中,以及我编写的一些三元组,包括一个有四个配料的披萨。正如@AKSW 建议的那样,我试图使浇头与众不同。

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

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

有趣的披萨定义:

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: *
4

1 回答 1

4

我用 Stardog 5.0 玩了一下,得到了更多的见解:

  1. 从 OWL DL 的角度来看,本体的表达能力足以推断出

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

于 2017-07-03T09:11:03.170 回答