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.