Rules are primarily intended for making logical inferences. What are you appear 
to be trying to do is ask questions of the data for which a query language like 
SPARQL is much better suited e.g.

PREFIX std: <http://yourdomain.com/ns#>
SELECT ?student ?subject ?bestScore
WHERE
{
  { 
    SELECT ?student MAX(?score) AS ?bestScore
    WHERE
     {
       ?student a std:Student ;
          std:hasResult ?result .
       ?result std:hasScore ?score
      } GROUP BY ?student
  }
  ?student std:hasResult ?result .
  ?result std:inSubject ?subject
}

I would suggest reading a tutorial such as 
https://www.cambridgesemantics.com/semantic-university/sparql-by-example

 This is just one such possible query and it makes assumptions about the 
structure of the data. But you should be  able to create a query that works 
your datamodel.

Failing that you can just use the Model/OntModel APIs directly to extract the 
relevant data and compute the calculation in Java. Sometimes people forget that 
they are working in a programming language and expect a library to magically do 
everything for them when what they actually needed to do is write some code for 
themselves!

Rob

On 27/09/2016 12:22, "javed khan" <[email protected]> wrote:

    Lorenz, any alternative way? I mean if there is any other rule where we can
    accomplish things like this?
    
    
    On Tue, Sep 27, 2016 at 2:56 AM, Lorenz B. <
    [email protected]> wrote:
    
    >
    >
    > > If we want to get the maximum score student got among three subjects
    > > (Robotics, Semantic Web, Research Methods) using Jena rules.
    > >
    > > ?x rdf:type std:Student + ?x std:RoboticsScore ?Rscore + ?x
    > > std:SemanticWebScore ?SMscore + ?x ResearchMethodScore ?RMscore
    > > + max(Rscore,SMscore,RMscore,maximun) THEN ????
    > >
    > > I have two questions here:
    > >
    > > 1) Is the max(Rscore,SMscore,RMscore,maximun) calculate max and assign
    > it
    > > to the (fourth)maximum variable?
    > Documentation is here:
    > https://jena.apache.org/documentation/inference/#builtin-primitives
    >
    > max(?a, ?b, ?c) takes two arguments ?a,?b and assigns the value to ?c
    > > 2) How would the THEN part be? *If these values give me max, then how
    > can I
    > > know that this maximum value belongs to Robotic, Semantic web or 
Research
    > > methods?*
    > Not possible, as max only assigns the maximum value to the variable as
    > you already know.
    > > *I want to determine "Favorite subject" of student so if a student got
    > max
    > > score in a subject, that will be his/her favorite subject.  *
    > >
    > --
    > Lorenz Bühmann
    > AKSW group, University of Leipzig
    > Group: http://aksw.org - semantic web research center
    >
    >
    




Reply via email to