Discussion:
Infer data property values
neha gupta
2016-11-16 13:53:58 UTC
Permalink
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
Lorenz B.
2016-11-16 14:21:28 UTC
Permalink
Post by neha gupta
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.
Post by neha gupta
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.
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.
Post by neha gupta
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.
Post by neha gupta
2) *How can I then save it as data property in a file for team1*? I have
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 ...
Post by neha gupta
Thanks
--
Lorenz BÃŒhmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center
neha gupta
2016-11-16 15:11:03 UTC
Permalink
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. <
Post by Lorenz B.
Post by neha gupta
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.
Post by neha gupta
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.
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.
Post by neha gupta
Is it the right approach? * inf.listResourcesWithProperty(
FavoriteStadium,
Post by neha gupta
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.
Post by neha gupta
2) *How can I then save it as data property in a file for team1*? I have
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 ...
Post by neha gupta
Thanks
--
Lorenz BÃŒhmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center
Lorenz Buehmann
2016-11-17 09:19:10 UTC
Permalink
Post by neha gupta
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,
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).
Post by neha gupta
I have saved all other properties (not in inference model, but traditional
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?
Post by neha gupta
Regards
On Wed, Nov 16, 2016 at 5:21 PM, Lorenz B. <
Post by Lorenz B.
Post by neha gupta
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.
Post by neha gupta
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.
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.
Post by neha gupta
Is it the right approach? * inf.listResourcesWithProperty(
FavoriteStadium,
Post by neha gupta
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.
Post by neha gupta
2) *How can I then save it as data property in a file for team1*? I have
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 ...
Post by neha gupta
Thanks
--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center
Continue reading on narkive:
Loading...