1

I have extended the original pizza.owl and have now the following SWRL rule in my Protege (Rules editor: Windows/Views/Ontology views/Rules):

Pizza(?p), 
hasIngredient(?p, ?ing1), hasIngredient(?p, ?ing2), 
hasCountryOfOrigin(?ing1, ?c1), hasCountryOfOrigin(?ing2, ?c1), 
differentFrom(?ing1, ?ing2) -> NationalPizza(?p)

The rule should assert NationalPizza for all pizza individuals where at least two ingredients (e.g. PizzaToppings) are from the same country (e.g. MeatTopping Lardon_Alsace and CreamTopping CrèmeFraîche_Normandie both have hasCountryOfOrigin equal to the individual France). The reasoner (Pellet) finds nothing. Can I use any swrlb function instead?

+++EDIT1+++

I have come up with the following solution:

Pizza(?p), 
hasIngredient(?p, ?ing1), hasIngredient(?p, ?ing2), 
hasCountryOfOrigin(?ing1, ?c1), hasCountryOfOrigin(?ing2, ?c1) -> NationalPizza(?p)

which gives correct result.

Alternatively, I also tried that way with OWL expressions:

Pizza(?p), (hasIngredient min 2 PizzaTopping)(?ing)  -> NationalPizza(?p)

but then how do I incorporate the condition that country must be the same? Any ideas?

+++EDIT2+++

I made following changes to my SWRL rule (based on @AKSW comment) in the SWRLTab:

Pizza(?p) ^ 
hasIngredient(?p, ?i1) ^ hasIngredient(?p, ?i2) ^ 
  hasName(?i1, ?ni1) ^ hasName(?i2, ?ni2) ^ swrlb:notEqual(?ni1, ?ni2) ^ 
hasCountryOfOrigin(?i1, ?c1) ^ hasCountryOfOrigin(?i2, ?c2) ^ 
  hasName(?c1, ?nc1) ^ hasName(?c2, ?nc2) ^ swrlb:equal(?nc1, ?nc2) 
-> NationalPizza(?p)

but the Pellet (incremental) reasoner does not assert the individual BlancheAuxLardonds_MaMère, which indeed has (at least) two different ingredients (Lardon_Alsace and Reblochon_LEcho-des-Alpages) from the same country (France).

+++EDIT3+++

I made following changes in the ontology (based on @AKSW comment):

  <rdf:Description>
        <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#AllDifferent"/>
        <owl:distinctMembers rdf:parseType="Collection">
            <rdf:Description rdf:about="http://www.co-ode.org/ontologies/pizza#CrèmeFraîche_Normandie"/>
            <rdf:Description rdf:about="http://www.co-ode.org/ontologies/pizza#Gorgonzola_Maribor"/>
            <rdf:Description rdf:about="http://www.co-ode.org/ontologies/pizza#Lardon_Alsace"/>
            <rdf:Description rdf:about="http://www.co-ode.org/ontologies/pizza#Mozzarella_Buffala"/>
            <rdf:Description rdf:about="http://www.co-ode.org/ontologies/pizza#Reblochon_LEcho-des-Alpages"/>
        </owl:distinctMembers>
    </rdf:Description>

Any help on that?

My ontology is here.

andrejt
  • 21
  • 3
  • 1
    First, all these pizzas are modelled as classes, not as individuals in [pizza.owl](https://protege.stanford.edu/ontologies/pizza/pizza.owl). Second, Pellet [supports](https://github.com/stardog-union/pellet/wiki/FAQ#does-pellet-support-rules-swrl-which-builtins) the so-called DL-safe rules only. I.e. one can not write something like `subClassOf(?p, Pizza)`. BTW, in SQWRL one can write something like `tbox:sca(?p, Pizza)`. SWRL builtins are rather for working with literals. And what is Lardon Alsace? I can't find this in `pizza.owl`. – Stanislav Kralin Mar 06 '18 at 09:58
  • `differentFrom` must be stated explicitly in the ontology...and as StanislavKralin said, there are no individuals unless you added some in your ontology which we don't know. – UninformedUser Mar 06 '18 at 11:05
  • @StanislavKralin thank you for your comments. I have added additional explanation to the EDIT part. – andrejt Mar 06 '18 at 20:59
  • @AKSW yes, I added my individuals. Please see the link to my ontology. – andrejt Mar 06 '18 at 21:09
  • I have updated the title to better match the content. – andrejt Mar 06 '18 at 23:44
  • Are you sure that your edited solution works? You did not state that `?ing1` and `?ing2` must be different things, thus, I'd assume that any `Pizza` becomes a `NationalPizza` – UninformedUser Mar 07 '18 at 04:22
  • `hasIngredient min 2 PizzaTopping` also needs different individuals. Moreover, you can't express what you want with class expressions, that actually the reason why people extended OWL with rules bymeans of SWRL. OWL class expressions do not have variables and they always describe a tree-like structure only – UninformedUser Mar 07 '18 at 04:24
  • @AKSW thanks for your comment. Please, see my new EDIT2 and updated ontology (link). Any new idea? – andrejt Mar 08 '18 at 14:08
  • It's the first time that you mention the SWRLTab...this plugin doesn't use the Pellet reasoner and inferences are only shown in the tab itslef - it uses the Drools rule engine. If you want to use the Pellet reasoner, you have to add the rule to the ontology via Rules tab. Moreover, individuals in your ontology have be distinct explicitly, i.e. `a owl:differentFrom b` – UninformedUser Mar 09 '18 at 04:14
  • @AKSW but you know that it is not possible to enter the swrlb functions in the Rules tab while it is possible to enter them in the SWRLTab and they are visible then in the Rules tab. Anyway, the rule is written to the ontology. So what is the solution? – andrejt Mar 12 '18 at 14:15
  • @AKSW I have implemented the `owl:distinctMembers` (see EDIT3). Still no result for my rule.... – andrejt Mar 12 '18 at 14:48
  • No more comments on that? – andrejt Mar 13 '18 at 15:30
  • You're using the SWRLTab, right? Thus, only the Drools engine will be used. The next step you can do is to debug your rule with the SQWRL Tab. Start with smaller queries and then add another atom to the rule. This helps to understand which atom doesn't match data. – UninformedUser Mar 14 '18 at 06:54

0 Answers0