On 12/11/13 15:13, Miguel Bento Alves wrote: > Dave, > > "Alternatively, Jena rules has the notion of a "functor" (bad name) which > is essentially a structured literal. So you can represent your Y/C pairs > as certainty(Y,C) and write rules which generate and match triples whose > object is a certainty(?x,?y) pair" > > > > You are saying something like: > (?x exa:p1 certainty(?y, ?c)) <- (?x exa:p11 certainty(?y, ?c)). > > (?x exa:p1 certainty(?y, ?c)) <- (?x exa:p12 certainty(?y, ?c)). > > (?x exa:p11 certainty(exa:o1, 0.8)) <- (?x exa:qvalue ?v), lessThan(?v, > 10). > > (?x exa:p12 certainty(exa:o2, 0.7)) <- (?x exa:qvalue ?v), ge(?v, 100). > > > ? > > Is this possible?
Yes. For example the rules for the OWL rule reasoner use this for brevity and a bit of efficiency. They glue the OWL RDF triples that make up restrictions into a functor, then make deductions on the basis of those functors, the functors are an intermediate step only. > How can I invoke a "structured literal” in a Sparql > command? You can't (other than as a literal with an odd data type), they are a non-standard datatype, which is why by default they are hidden from external access. Normally you would have other rules which extract the pieces of the functors that you want as normal triples (e.g. back into an n-ary relationships using bNodes) for query or access them programmatically. [I'm not sure this whole mechanism was worth it in retrospect, and if designing a new rule engine I wouldn't include it but there are no plans to remove it.] Dave > > MBA > > On 12/11/13 14:31, "Dave Reynolds" <[email protected]> wrote: > >> On 12/11/13 11:54, Miguel Bento Alves wrote: >>> Dear Dave, >>> >>> Can I express myself in Prolog? >>> >>> I want something like: >>> >>> v(s1, 8). >>> v(s2, 120). >>> >>> p1(X, Y, C):- >>> p11(X, Y, C). >>> >>> >>> p1(X, Y, C):- >>> p12(X, Y, C). >>> >>> >>> p11(X, o1, 0.8):- >>> v(X, V), >>> V < 10. >>> >>> >>> p12(X, o1, 0.7):- >>> v(X, V), >>> V >= 100. >>> >>> >>> p1(s1, Y, C)? >>> Y = o1, C = 0.8 >>> >>> p1(s2, Y, C)? >>> Y = o1, C = 0.7 >>> >>> >>> >>> In best of my knowledge, is not possible what I want. But I¹m new in >>> Jena >>> and perhaps there are a solution that I can¹t figure out. I think that >>> is >>> not possible because I need a quad: Subject, Property, Object, >>> Confidence. >>> I tried with blank nodes but I didn¹t had success. >> >> If that's really what you want then that is more or less possible, >> however I think you'll find you need more. >> >> The issue is that in your example there is no overlap of rules. So p11 >> and p12 never occur together, indeed for values of V between 10 and 99 >> there's no value for p1. Normally once you have uncertainty measures you >> find cases where there are multiple routes to a conclusion, each of >> which contributes some confidence/certainty/belief/whatever. In which >> case you need to trace out all the possible routes and combine the >> confidence measures from each route, which in turn requires dependency >> assumptions. If that's where you are headed them I would start with a >> tool designed for that job, not start with a rule based system and hope >> to extend it. >> >> However, if there are *really* no overlaps, and only ever a single >> deduction path for a single conclusion, and that won't change, then you >> could do something in Jena. >> >> There are two options for handling n-ary relations in Jena rules. >> >> First you can represent them as groups of triples. To deduce an instance >> of an n-ary relationship from a rule then you need to create a bNode to >> represent the instance. For this you can use makeTemp (which a guard to >> prevent multiple instantiation) or makeSkolem. The latter is probably >> the better choice. >> >> Alternatively, Jena rules has the notion of a "functor" (bad name) which >> is essentially a structured literal. So you can represent your Y/C pairs >> as certainty(Y,C) and write rules which generate and match triples whose >> object is a certainty(?x,?y) pair. By default these literals are kept >> internal to the inference engine but there is an option to make them >> visible to external queries (PROPenableFunctorFiltering). >> >> Dave >> >> >>> >>> MBA >>> >>> >>> On 12/11/13 11:19, "Dave Reynolds" <[email protected]> wrote: >>> >>>> Depending on exactly what semantics you want for confidence >>>> coefficients >>>> then you probably want to look at a Bayesian network software. >>>> >>>> Dave >>>> >>>> On 12/11/13 09:04, Miguel Bento Alves wrote: >>>>> >>>>> >>>>> I want to introduce a confidence coefficient in my rules. For >>>>> instance, >>>>> in >>>>> the example below, let's consider that p11 has a confidence >>>>> coefficient >>>>> of >>>>> 0.8 while p12 has a confidence coefficient of 0.7. When ?x exa:p1 ?y >>>>> happens >>>>> I want to know the confidence of this conclusion. Any ideas? I have >>>>> been >>>>> study but I couldn't figure out a good solution. >>>>> >>>>> (?x exa:p1 ?y) <- (?x exa:p11 ?y). >>>>> >>>>> (?x exa:p1 ?y) <- (?x exa:p12 ?y). >>>>> >>>>> (?x exa:p11 exa:o1) <- (?x exa:qvalue ?v), lessThan(?v, 10). >>>>> >>>>> (?x exa:p12 exa:o2) <- (?x exa:qvalue ?v), ge(?v, 100). >>>>> >>>>> MBA >>>>> >>>>> >>>>> >>>> >>> >>> >> > >
