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/11/16 13:53:58 UTC

Infer data property values

Hello

I have a data property in my owl file: "FavoriteStadium" for a team.
Triples will be like team1  FavoriteStadium   ?stadium.

I will infer the instances using a Jena rule like if a team win % is more
in a particular stadium, it will be her favorite stadium.
I have two questions here:

1) How can I get the instances like  team1  FavoriteStadium   ?stadium.
Is it the right approach? * inf.listResourcesWithProperty(FavoriteStadium,
favVariable);*

2) *How can I then save it as data property in a file for team1*? I have
other properties like this:
team1  Wins  10
team1  Goals  150
team1  income  70%

Similarly I want to add it like
team1  FavoriteStadium  ?SomeStadium

Thanks

Re: Infer data property values

Posted by Lorenz Buehmann <bu...@informatik.uni-leipzig.de>.

On 16.11.2016 16:11, neha gupta wrote:
> Hello Lorenz Thanks again. My variable is like
>
>  OntClass favVariable = model.getOntClass(ns + "FavioriteStadium");
>
> //then Jena rule
>
> Since I will login to the system as team1, all information saved will be
> for team1. Similarly for other teams.
>
> In my owl file, I have instances (Resources) like "Manchester, Arsenal,
> Chelsea etc" for objects of my triples like:
> team1  FavStadium  Manchester
> team2  FavStadium  Chelsea etc
>
> If I just write the inference model inf to the file like inf.write(), where
> it will be saved? As data property?
What means "where"? If you write the model to disk, it will be saved in
the RDF format that you specify and to a file that you specify. All
triples will be contained in that file.
And whether it is a data property or object property depends on how you
define the property in your ontology. If nothing is set, then it's
simply an RDF property. And again, it depends on how you model the
stadiums, either as string values (which is weird from my point of view)
or as resources(resp. URI).
>
> I have saved all other properties (not in inference model, but traditional
> model) like:
>
> team1.setPropertyValue(). I dont know how to do this in the inf model case.
This doesn't "save" anything, but adds it to the model. I don't see the
problem now.
Why can't you add the stadium to add team?
>
> Regards
>
>
>
> On Wed, Nov 16, 2016 at 5:21 PM, Lorenz B. <
> buehmann@informatik.uni-leipzig.de> wrote:
>
>>
>>> Hello
>>>
>>> I have a data property in my owl file: "FavoriteStadium" for a team.
>>> Triples will be like team1  FavoriteStadium   ?stadium.
>> This is NOT a triple but a triple pattern in SPARQL...triples do not
>> contain variables.
>>> I will infer the instances using a Jena rule like if a team win % is more
>>> in a particular stadium, it will be her favorite stadium.
>>> I have two questions here:
>>>
>>> 1) How can I get the instances like  team1  FavoriteStadium   ?stadium.
>> This is not an instance! Again, this is a triple pattern. An instance
>> would be team1.
>>> Is it the right approach? * inf.listResourcesWithProperty(
>> FavoriteStadium,
>>> favVariable);*
>> This will list the subjects, e.g. team1 in your example, but given that
>> favVariable is a variable, this will not work. Your example is confusing
>> as you're mixing up SPARQL variable and Java variables. If favVariable
>> is some RDFNode, i.e. in your case an RDF resource that denotes a
>> particular stadium, then it will return all resources whose favorite
>> stadium is the stadium denoted by your Java variable favStadium.
>>> 2) *How can I then save it as data property in a file for team1*? I have
>>> other properties like this:
>>> team1  Wins  10
>>> team1  Goals  150
>>> team1  income  70%
>>>
>>> Similarly I want to add it like
>>> team1  FavoriteStadium  ?SomeStadium
>> Save it as data property? What does this mean? I would assume that a
>> stadium is an RDF resource, not a plain String literal.
>> And what do you mean by save to file? You can serialize the whole RDF
>> model to disk, or you could generate a model for team1 only and
>> serialize write it to disk, or you could write it as CSV to disk ,or ...
>>> Thanks
>>>
>> --
>> Lorenz B�hmann
>> AKSW group, University of Leipzig
>> Group: http://aksw.org - semantic web research center
>>
>>


Re: Infer data property values

Posted by neha gupta <ne...@gmail.com>.
Hello Lorenz Thanks again. My variable is like

 OntClass favVariable = model.getOntClass(ns + "FavioriteStadium");

//then Jena rule

Since I will login to the system as team1, all information saved will be
for team1. Similarly for other teams.

In my owl file, I have instances (Resources) like "Manchester, Arsenal,
Chelsea etc" for objects of my triples like:
team1  FavStadium  Manchester
team2  FavStadium  Chelsea etc

If I just write the inference model inf to the file like inf.write(), where
it will be saved? As data property?

I have saved all other properties (not in inference model, but traditional
model) like:

team1.setPropertyValue(). I dont know how to do this in the inf model case.

Regards



On Wed, Nov 16, 2016 at 5:21 PM, Lorenz B. <
buehmann@informatik.uni-leipzig.de> wrote:

>
>
> > Hello
> >
> > I have a data property in my owl file: "FavoriteStadium" for a team.
> > Triples will be like team1  FavoriteStadium   ?stadium.
> This is NOT a triple but a triple pattern in SPARQL...triples do not
> contain variables.
> >
> > I will infer the instances using a Jena rule like if a team win % is more
> > in a particular stadium, it will be her favorite stadium.
> > I have two questions here:
> >
> > 1) How can I get the instances like  team1  FavoriteStadium   ?stadium.
> This is not an instance! Again, this is a triple pattern. An instance
> would be team1.
> > Is it the right approach? * inf.listResourcesWithProperty(
> FavoriteStadium,
> > favVariable);*
> This will list the subjects, e.g. team1 in your example, but given that
> favVariable is a variable, this will not work. Your example is confusing
> as you're mixing up SPARQL variable and Java variables. If favVariable
> is some RDFNode, i.e. in your case an RDF resource that denotes a
> particular stadium, then it will return all resources whose favorite
> stadium is the stadium denoted by your Java variable favStadium.
> >
> > 2) *How can I then save it as data property in a file for team1*? I have
> > other properties like this:
> > team1  Wins  10
> > team1  Goals  150
> > team1  income  70%
> >
> > Similarly I want to add it like
> > team1  FavoriteStadium  ?SomeStadium
> Save it as data property? What does this mean? I would assume that a
> stadium is an RDF resource, not a plain String literal.
> And what do you mean by save to file? You can serialize the whole RDF
> model to disk, or you could generate a model for team1 only and
> serialize write it to disk, or you could write it as CSV to disk ,or ...
> >
> > Thanks
> >
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>

Re: Infer data property values

Posted by "Lorenz B." <bu...@informatik.uni-leipzig.de>.

> Hello
>
> I have a data property in my owl file: "FavoriteStadium" for a team.
> Triples will be like team1  FavoriteStadium   ?stadium.
This is NOT a triple but a triple pattern in SPARQL...triples do not
contain variables.
>
> I will infer the instances using a Jena rule like if a team win % is more
> in a particular stadium, it will be her favorite stadium.
> I have two questions here:
>
> 1) How can I get the instances like  team1  FavoriteStadium   ?stadium.
This is not an instance! Again, this is a triple pattern. An instance
would be team1.
> Is it the right approach? * inf.listResourcesWithProperty(FavoriteStadium,
> favVariable);*
This will list the subjects, e.g. team1 in your example, but given that
favVariable is a variable, this will not work. Your example is confusing
as you're mixing up SPARQL variable and Java variables. If favVariable
is some RDFNode, i.e. in your case an RDF resource that denotes a
particular stadium, then it will return all resources whose favorite
stadium is the stadium denoted by your Java variable favStadium.
>
> 2) *How can I then save it as data property in a file for team1*? I have
> other properties like this:
> team1  Wins  10
> team1  Goals  150
> team1  income  70%
>
> Similarly I want to add it like
> team1  FavoriteStadium  ?SomeStadium
Save it as data property? What does this mean? I would assume that a
stadium is an RDF resource, not a plain String literal.
And what do you mean by save to file? You can serialize the whole RDF
model to disk, or you could generate a model for team1 only and
serialize write it to disk, or you could write it as CSV to disk ,or ...
>
> Thanks
>
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center