You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by neha gupta <ne...@gmail.com> on 2016/09/11 19:14:19 UTC

Calculating numeric values of Data property in Ontology

I have data properties in my ontology as: Java score=55, another data
property C++ score=60, and lets suppose Semantic web score=80. Can we add
these three scores in Jena and if yes how?

But we have to do it for each instance of Student like student1, student2
etc

 Property prop1= model.getProperty(ns,"JavaScore");

 Property prop2= model.getProperty(ns,"C++Score");
 Property prop3= model.getProperty(ns,"Semantic webScore");

student1.addLiteral(prop, javascore);
student1.addLiteral(prop, c++score);
student1.addLiteral(prop, semanticweb score");   etc

Re: Calculating numeric values of Data property in Ontology

Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
Which details do you want to see? GetInt() returns just the integer
valueso fthe object of a triple, if and only if it's an integer literal.

If you want to modify your data such that the sum is computed
automatically for each student that has all scores, use a SPARQL Update
query.

On 12.09.2016 10:20, neha gupta wrote:
> Thanks Andy, how can I use the getInt here as I have not seen much details
> about it on Jena page except
>
>  getInt
> <https://jena.apache.org/documentation/javadoc/jena/org/apache/jena/rdf/model/Statement.html#getInt-->
> ()
> Return the object of the statement.
>
>
>
> On Mon, Sep 12, 2016 at 1:10 AM, Andy Seaborne <an...@apache.org> wrote:
>
>> 1/ SPARQL
>>
>> 2/ Literal.getInt
>>
>>         Andy
>>
>>
>> On 12/09/16 09:04, neha gupta wrote:
>>
>>> Yes I want the arithmetic calculation of these literals. If students have
>>> these individual scores in three subjects, how can I calculate the total
>>> of
>>> these subjects score?
>>>
>>>
>>>
>>> On Mon, Sep 12, 2016 at 12:18 AM, George News <ge...@gmx.net>
>>> wrote:
>>>
>>> I think what he/she wants it the addition (1+1=2). He wants to know if
>>>> it is possible to automatically create a literal that is the addition of
>>>> some values.
>>>>
>>>> I think you should do it manually, or otherwise you can create a SPARQL
>>>> sentence that does the addition.
>>>>
>>>> Regards
>>>>
>>>> On 12/09/2016 8:01, Lorenz Buehmann wrote:
>>>>
>>>>> You already showed us code that add literals values (the scores) to
>>>>> resources, so what's the question now?
>>>>>
>>>>>
>>>>> On 11.09.2016 21:14, neha gupta wrote:
>>>>>
>>>>>> I have data properties in my ontology as: Java score=55, another data
>>>>>> property C++ score=60, and lets suppose Semantic web score=80. Can we
>>>>>>
>>>>> add
>>>>> these three scores in Jena and if yes how?
>>>>>> But we have to do it for each instance of Student like student1,
>>>>>>
>>>>> student2
>>>>> etc
>>>>>>  Property prop1= model.getProperty(ns,"JavaScore");
>>>>>>
>>>>>>  Property prop2= model.getProperty(ns,"C++Score");
>>>>>>  Property prop3= model.getProperty(ns,"Semantic webScore");
>>>>>>
>>>>>> student1.addLiteral(prop, javascore);
>>>>>> student1.addLiteral(prop, c++score);
>>>>>> student1.addLiteral(prop, semanticweb score");   etc
>>>>>>
>>>>>>
>>>>>


Re: Calculating numeric values of Data property in Ontology

Posted by neha gupta <ne...@gmail.com>.
Thanks Andy, how can I use the getInt here as I have not seen much details
about it on Jena page except

 getInt
<https://jena.apache.org/documentation/javadoc/jena/org/apache/jena/rdf/model/Statement.html#getInt-->
()
Return the object of the statement.



On Mon, Sep 12, 2016 at 1:10 AM, Andy Seaborne <an...@apache.org> wrote:

> 1/ SPARQL
>
> 2/ Literal.getInt
>
>         Andy
>
>
> On 12/09/16 09:04, neha gupta wrote:
>
>> Yes I want the arithmetic calculation of these literals. If students have
>> these individual scores in three subjects, how can I calculate the total
>> of
>> these subjects score?
>>
>>
>>
>> On Mon, Sep 12, 2016 at 12:18 AM, George News <ge...@gmx.net>
>> wrote:
>>
>> I think what he/she wants it the addition (1+1=2). He wants to know if
>>> it is possible to automatically create a literal that is the addition of
>>> some values.
>>>
>>> I think you should do it manually, or otherwise you can create a SPARQL
>>> sentence that does the addition.
>>>
>>> Regards
>>>
>>> On 12/09/2016 8:01, Lorenz Buehmann wrote:
>>>
>>>> You already showed us code that add literals values (the scores) to
>>>> resources, so what's the question now?
>>>>
>>>>
>>>> On 11.09.2016 21:14, neha gupta wrote:
>>>>
>>>>> I have data properties in my ontology as: Java score=55, another data
>>>>> property C++ score=60, and lets suppose Semantic web score=80. Can we
>>>>>
>>>> add
>>>
>>>> these three scores in Jena and if yes how?
>>>>>
>>>>> But we have to do it for each instance of Student like student1,
>>>>>
>>>> student2
>>>
>>>> etc
>>>>>
>>>>>  Property prop1= model.getProperty(ns,"JavaScore");
>>>>>
>>>>>  Property prop2= model.getProperty(ns,"C++Score");
>>>>>  Property prop3= model.getProperty(ns,"Semantic webScore");
>>>>>
>>>>> student1.addLiteral(prop, javascore);
>>>>> student1.addLiteral(prop, c++score);
>>>>> student1.addLiteral(prop, semanticweb score");   etc
>>>>>
>>>>>
>>>>
>>>>
>>>
>>

Re: Calculating numeric values of Data property in Ontology

Posted by Andy Seaborne <an...@apache.org>.
1/ SPARQL

2/ Literal.getInt

	Andy

On 12/09/16 09:04, neha gupta wrote:
> Yes I want the arithmetic calculation of these literals. If students have
> these individual scores in three subjects, how can I calculate the total of
> these subjects score?
>
>
>
> On Mon, Sep 12, 2016 at 12:18 AM, George News <ge...@gmx.net> wrote:
>
>> I think what he/she wants it the addition (1+1=2). He wants to know if
>> it is possible to automatically create a literal that is the addition of
>> some values.
>>
>> I think you should do it manually, or otherwise you can create a SPARQL
>> sentence that does the addition.
>>
>> Regards
>>
>> On 12/09/2016 8:01, Lorenz Buehmann wrote:
>>> You already showed us code that add literals values (the scores) to
>>> resources, so what's the question now?
>>>
>>>
>>> On 11.09.2016 21:14, neha gupta wrote:
>>>> I have data properties in my ontology as: Java score=55, another data
>>>> property C++ score=60, and lets suppose Semantic web score=80. Can we
>> add
>>>> these three scores in Jena and if yes how?
>>>>
>>>> But we have to do it for each instance of Student like student1,
>> student2
>>>> etc
>>>>
>>>>  Property prop1= model.getProperty(ns,"JavaScore");
>>>>
>>>>  Property prop2= model.getProperty(ns,"C++Score");
>>>>  Property prop3= model.getProperty(ns,"Semantic webScore");
>>>>
>>>> student1.addLiteral(prop, javascore);
>>>> student1.addLiteral(prop, c++score);
>>>> student1.addLiteral(prop, semanticweb score");   etc
>>>>
>>>
>>>
>>
>

Re: Calculating numeric values of Data property in Ontology

Posted by neha gupta <ne...@gmail.com>.
Yes I want the arithmetic calculation of these literals. If students have
these individual scores in three subjects, how can I calculate the total of
these subjects score?



On Mon, Sep 12, 2016 at 12:18 AM, George News <ge...@gmx.net> wrote:

> I think what he/she wants it the addition (1+1=2). He wants to know if
> it is possible to automatically create a literal that is the addition of
> some values.
>
> I think you should do it manually, or otherwise you can create a SPARQL
> sentence that does the addition.
>
> Regards
>
> On 12/09/2016 8:01, Lorenz Buehmann wrote:
> > You already showed us code that add literals values (the scores) to
> > resources, so what's the question now?
> >
> >
> > On 11.09.2016 21:14, neha gupta wrote:
> >> I have data properties in my ontology as: Java score=55, another data
> >> property C++ score=60, and lets suppose Semantic web score=80. Can we
> add
> >> these three scores in Jena and if yes how?
> >>
> >> But we have to do it for each instance of Student like student1,
> student2
> >> etc
> >>
> >>  Property prop1= model.getProperty(ns,"JavaScore");
> >>
> >>  Property prop2= model.getProperty(ns,"C++Score");
> >>  Property prop3= model.getProperty(ns,"Semantic webScore");
> >>
> >> student1.addLiteral(prop, javascore);
> >> student1.addLiteral(prop, c++score);
> >> student1.addLiteral(prop, semanticweb score");   etc
> >>
> >
> >
>

Re: Calculating numeric values of Data property in Ontology

Posted by George News <ge...@gmx.net>.
I think what he/she wants it the addition (1+1=2). He wants to know if
it is possible to automatically create a literal that is the addition of
some values.

I think you should do it manually, or otherwise you can create a SPARQL
sentence that does the addition.

Regards

On 12/09/2016 8:01, Lorenz Buehmann wrote:
> You already showed us code that add literals values (the scores) to
> resources, so what's the question now?
> 
> 
> On 11.09.2016 21:14, neha gupta wrote:
>> I have data properties in my ontology as: Java score=55, another data
>> property C++ score=60, and lets suppose Semantic web score=80. Can we add
>> these three scores in Jena and if yes how?
>>
>> But we have to do it for each instance of Student like student1, student2
>> etc
>>
>>  Property prop1= model.getProperty(ns,"JavaScore");
>>
>>  Property prop2= model.getProperty(ns,"C++Score");
>>  Property prop3= model.getProperty(ns,"Semantic webScore");
>>
>> student1.addLiteral(prop, javascore);
>> student1.addLiteral(prop, c++score);
>> student1.addLiteral(prop, semanticweb score");   etc
>>
> 
> 

Re: Calculating numeric values of Data property in Ontology

Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.
You already showed us code that add literals values (the scores) to
resources, so what's the question now?


On 11.09.2016 21:14, neha gupta wrote:
> I have data properties in my ontology as: Java score=55, another data
> property C++ score=60, and lets suppose Semantic web score=80. Can we add
> these three scores in Jena and if yes how?
>
> But we have to do it for each instance of Student like student1, student2
> etc
>
>  Property prop1= model.getProperty(ns,"JavaScore");
>
>  Property prop2= model.getProperty(ns,"C++Score");
>  Property prop3= model.getProperty(ns,"Semantic webScore");
>
> student1.addLiteral(prop, javascore);
> student1.addLiteral(prop, c++score);
> student1.addLiteral(prop, semanticweb score");   etc
>