Schema for toys and toy parts:
ex#Toy [ ex#hasPart *=> ex#ToyPart ] . ex#ToyPart [] . ex#ToyPart [ ex#hasPart *=> ex#ToyPart ] . ex#ToyPart [] . |
Note that the schema above can be modelled in semAuth also like this:
ex#ToyPart [ ex#hasPart *=> ex#ToyPart ] . ex#ToyPart [] . ex#Toy [ ex#hasPart *=> ex#ToyPart ] . ex#ToyPart [] . |
Some toy parts:
The part list of a fire engine:
Note that in our ontology erniesFireEngine does *not* have a wheel *directly*. Instead the fire engine has a driveSystem, which in turn has a wheel as it's part.
The part list of our horse:
turtle: ex#horse rdf:type ex#Pet . ex#horse [ ex#hasPart -> ex#head ] . ex#horse [ ex#hasPart -> ex#hair ] . |
If we now query for toys with wheels we don't get a single answer! (The answer to the next query is *not* given already in the fact base because "wheel" is not directly a part of the fire engine, but part of the drive system instead)
@{
toysWithWheels
}
?-
|
What we need to do here is to gather and collect all *indirect* parts of toys. This is the place where a handy crafted rule comes into place. We get the expected result "erniesFireEngine" if we add a rule to the ontology which inferences all subparts of a toy.
|
@{
hasSubPart
}
?-
@{
hasSubPartRule
}
|
In order to make all the toys with wheels easily accesible we again define them via a classification rule:
@{
toyWithWheelsClassification
}
?-
@{
toyWithWheelsClassificationRule
}
|