Thank you Niels, you made my day with the notEqual() function. The built-in
primitives page that you suggested is a gold mine.

@Dave: Jena does support N3 rules






On Thu, Aug 4, 2016 at 8:06 PM, Niels Andersen <[email protected]> wrote:

> Here is how I would do it:
>
>
>
> [RuleMotherMutipleBirths: (?person rdf:Type ex:FemalePerson) (?parent
> ex:person_Child ?Child1) (?parent ex:person_Child ?Child2)
> notEqual(?Child1,?Child2) (?Child1 ex:person_Birthday ?ChildBirthday)
> (?Child2 ex:person_ Birthday? ChildBirthday)
>
> -> (?parent ex:person_ChildrenType ex:HasMultipleBirth) (?Child1
> ex:sameBirth ?Child2) (?Child2 ex: sameBirth ?Child1)]
>
>
>
> A couple of things to watch out for here:
>
> ·         This rule will cover any multi berth situation (twins, triplets,
> etc)
>
> ·         The kids must come from the same birth, not just have the same
> birthday or age. Therefore the parent must be a female.
>
> ·         The rule will not work if the twins are born on two different
> days.
>
> ·         Not sure the word Birth is the right one, try to find a better
> one.
>
>
>
> Look at https://jena.apache.org/documentation/inference/#
> builtin-primitives for inspiration.
>
>
>
> Now you can write a rule that shows that a man has twins. I’ll leave that
> for you to try.
>
>
>
> Niels
>
>
>
>
>
> -----Original Message-----
>
> From: lookman sanni [mailto:[email protected]]
>
> Sent: Wednesday, August 3, 2016 22:55
>
> To: [email protected]
>
> Subject: RE: Notation 3 Rule specification
>
>
>
> Thanks Niels for the reply.
>
>
>
> [AgeRule: (?person1 ex:person_Age ?age) (?person2 ex:person_Age ?age) ->
>
> (?person1 ex:sameAge ?person2)] works fine for the purpose.
>
>
>
> Now let's assume that person1 has two properties: sonAge and daughterAge
> and I would like to infer a rule like person1 hasTwins. How would I write
> it ?
>
>
>
> Thanks, Lookman
>
> Le 4 août 2016 06:42, "Niels Andersen" <[email protected]> a écrit :
>
>
>
> > A general recommendation, please make sure that the properties that
>
> > you choose clearly describes the direction of the relationship. It is
>
> > not clear if ?f or ?a is the father.
>
> >
>
> > There are probably a million opinions about how to do this, my general
>
> > recommendation is to create properties that show the class to the left
>
> > and the relationship to the right, so ?a ex:person_Father ?b would
>
> > mean that ?a's father is ?b. It also makes it clear that the domain of
>
> > ex:person_Father is ex:Person and the range of ex:person_Father is
>
> > ex:Father.
>
> >
>
> > Not sure if I understand your question, but you could do the following
>
> > to compare ages
>
> > [AgeRule: (?person1 ex:person_Age ?age) (?person2 ex:person_Age ?age)
>
> > ->
>
> > (?person1 ex:sameAge ?person2)]
>
> >
>
> > This rule would only trigger if both ?person1 and ?person2 are the
>
> > same age.
>
> >
>
> > More specifically you could say:
>
> >
>
> > [UncleRule: (?person experson_Father ?father) (?father
>
> > ex:person_Brother
>
> > ?uncle) -> (?person ex:person_Uncle ?uncle)]
>
> > [UncleAgeRule: (?person1 ex:person_Uncle ?person2) (?person1
>
> > ex:person_Age
>
> > ?age) (?person2 ex:person_Age ?age) -> (?person1
>
> > ex:hasUncleWithSameAge ?person2)]
>
> >
>
> > Not sure why you would do that, but it is just an example.
>
> >
>
> > Niels
>
> >
>
> >
>
> > -----Original Message-----
>
> > From: lookman sanni [mailto:[email protected]]
>
> > Sent: Wednesday, August 3, 2016 20:37
>
> > To: [email protected]
>
> > Subject: Notation 3 Rule specification
>
> >
>
> > Hi all,
>
> >
>
> > I am beginning with Jena and I struggle with the specification of a
>
> > rule that would help infer new statements.
>
> >
>
> > More concretely, I would like to know how to compare values of
>
> > different properties of a same resource in a rule file, following the n3
> syntax.
>
> >
>
> > E.g. [rule1: (?f pre:father ?a) (?u pre:brother ?f) -> (?u pre:uncle
>
> > ?a)]
>
> >
>
> > If we assume f and u have a property age and I would like to test
>
> > whether that property has the same value or not for both, how would I do
> it ?
>
> >
>
> > Thanks, Lookman
>
> >
>



-- 
Best Regards

Lookman SANNI

Reply via email to