| 1 | = PimoInference = |
| 2 | |
| 3 | We do '''inference during insert''' into the pimo. The rules used for inference are defined in a Jena rules file, you can [source:branches/gnowsis0.9/gnowsis-server/src/java/org/gnowsis/pimo/impl/rules/pimo-rdfs.rules read the rules]. Based on these rules, additional triples are created during insert. Also when you delete triples, the same rules are used to entail the other triples that have to be deleted. To limit the complexity, we '''limit inference to the TBox'''. So we infer the subclass and sub-property relations and also inverse triples. We do not infer instance relations and individual triples. When querying the pimo-service, you can rely on all subclass and subproperty and inverse relations. The missing Abox-related relations can be easily added, see below. |
| 4 | |
| 5 | When you want to add many triples yourself using the inference, use the following methods. If you insert to PimoStorage directly, no inference will be done (for performance reasons). |
| 6 | * PimoService.performAdd() |
| 7 | * PimoService.performDelete() |
| 8 | * PimoService.performUpdate() |
| 9 | |
| 10 | === Additional triples inserted by the service === |
| 11 | As we inference all subclass and sub-property relations, we lose the original super-class of a class and it is non-trivial to find it. So we decided to add additional ''helping'' triples that we find these assertions: |
| 12 | |
| 13 | * the direct superclass of a class '''?subclass pimo_api:directSubClassOf ?superclass''' |
| 14 | * the direct superproperty of a property '''?subproperty pimo_api:directSubPropertyOf ?superproperty''' |
| 15 | * namespace is http://ontologies.opendfki.de/repos/ontologies/pim/pimo-api# |
| 16 | |
| 17 | If you add triples to the PimoStorage, you should also add these helper triples as some gui components depend on it. |
| 18 | |
| 19 | === Querying with regards to Abox inference === |
| 20 | To get all instances of a class ClassX |
| 21 | |
| 22 | |
| 23 | |
| 24 | see also: |
| 25 | * [http://en.wikipedia.org/wiki/Tbox Tbox] |
| 26 | * [http://en.wikipedia.org/wiki/Abox Abox] |
| 27 | |
| 28 | |
| 29 | |
| 30 | = Tips on inferencing by Michael Sintek = |
| 31 | this here taken from an e-mail from michael sintek, our local [http://en.wikipedia.org/wiki/Demiurge demiurge] of inference: |
| 32 | |
| 33 | I had a look at the Sesame RDFS implementation, which is quite nice: |
| 34 | they use a set of rules (implemented in Java!) for a forward rule |
| 35 | engine (probably using some Rete algorithm). |
| 36 | |
| 37 | The rules (for Sesame2) are here: |
| 38 | |
| 39 | http://www.openrdf.org/doc/sesame2/api/org/openrdf/sesame/sailimpl/inferencer/RDFSRules.html |
| 40 | |
| 41 | If you don't want the complete inferences, |
| 42 | simply remove some of them, e.g. the rules |
| 43 | for adding types: |
| 44 | |
| 45 | rule rdfs9_1: xxx rdfs:subClassOf yyy && (nt) aaa rdf:type xxx |
| 46 | --> (t1) aaa rdf:type yyy (t2) |
| 47 | |
| 48 | rule rdfs9_2: aaa rdf:type xxx && (nt) xxx rdfs:subClassOf yyy |
| 49 | --> (t1) aaa rdf:type yyy (t2) |
| 50 | |
| 51 | I could imagine that creating a subclass of RDFSRules and removing these |
| 52 | rules will do the magic already, but I have never looked at the code. |
| 53 | Anyway, should be trivial ... |
| 54 | |
| 55 | At least you could start with this implementation -- doing the |
| 56 | entailment stuff from scratch is really nasty (you need |
| 57 | something like a semi-naive bottom-up evaluation, otherwise |
| 58 | you will derive the same new triples over and over again). |
| 59 | |
| 60 | == Comment by Florian Mittag == |
| 61 | |
| 62 | We tried to do just this, but it turned out to be anything else than trivial. The inference engine of sesame described above is only applicable on !MemoryStore, but we need it for a !NativeStore. Converting the code to do this would mean to implement an inferencer on the native sail, which is quite complicated due to many dependencies on the inner working of the !MemoryStore. |
| 63 | |
| 64 | Gunnar hacked an improvement of the Jena inferencer, that will do what we want with little transactions (ie only one). Additionaly we will try to create all necessary triples on creation or deletion of classes and things, so an inference engine hopefully won't be needed. Still, it is good to have a backup ;-) |