Re: Struggling with rules

2016-09-29 Thread Martynas Jusevičius
Thank you Dave.

I dropped the rules in this case and solved it by walking up the
superclasses, dragging a Map along and augmenting
it with arguments for which there is no map key.

On Thu, Sep 29, 2016 at 10:33 AM, Dave Reynolds
 wrote:
> Hi Martynas,
>
> As Adrian says the problem is your "unless". That makes this a non-monotonic
> problem hence you needing to use the noValue predicate.
>
> Jena rules work OK in the monotonic case that they were designed for but
> allowing noValue and its kin that was a mistake and the engine isn't well
> suited to this sort of usage.
>
> That said I would have expected your first rule to work, it's the second
> case that is tricky. NoValue only allows you to check for absence of a
> triple whereas you need to check for absence of a triple pattern. So your:
>
> ...
> noValue(?template ?subArg),
> noValue(?subArg  ?predicate)
> ...
>
> will stop the rule firing if the template has any param, rather than if it
> has a param with the given predicate. There's no equivalent of noValue for
> such predicate chains. You could write one but you would still be dealing
> with non-monotonic rules and I wouldn't guarantee it would work as you
> expect.
>
> Dave
>
>
> On 28/09/16 20:20, Martynas Jusevičius wrote:
>>
>> Hey,
>>
>> is it possible to express such condition using Jena rules:
>> "Subclasses inherit parameter arguments from superclasses, unless an
>> argument with the same predicate already is a subclass parameter"?
>>
>> For example
>>
>> # 1
>>
>> :SuperClass ldt:param [ a ldt:Argument ; spl:predicate foaf:name ],
>>[ a ldt:Argument ; spl:predicate dct:title ] .
>>
>> :SubClass rdfs:subClassOf :SuperClass .
>>
>> should infer new triples:
>>
>> :SubClass ldt:param [ a ldt:Argument ; spl:predicate foaf:name ],
>>[ a ldt:Argument ; spl:predicate dct:title ] .
>>
>> # 2
>>
>> :SuperClass ldt:param [ a ldt:Argument ; spl:predicate foaf:name ],
>>[ a ldt:Argument ; spl:predicate dct:title ] .
>>
>> :SubClass rdfs:subClassOf :SuperClass ;
>>ldt:param [ a ldt:Argument ; spl:predicate dct:title ] ,
>>  [ a ldt:Argument ; spl:predicate sioc:name ] .
>>
>> should infer new triples:
>>
>> :SubClass ldt:param [ a ldt:Argument ; spl:predicate foaf:name ] .
>> # no dct:title param inferred, because it exists already
>>
>>
>> What I use currently is this:
>>
>> [arg1:  (?template rdf:type ),
>> (?template  ?arg), (?arg rdf:type
>> ), (?subTemplate rdfs:subClassOf
>> ?template), (?subTemplate rdf:type
>> ), noValue(?subTemplate
>> ) -> (?subTemplate
>>  ?arg)]
>>
>> [arg2:  (?template rdf:type ),
>> (?template  ?arg), (?arg rdf:type
>> ), (?subTemplate rdfs:subClassOf
>> ?template), (?subTemplate rdf:type
>> ), (?arg
>>  ?predicate), (?subTemplate
>>  ?subArg), noValue(?template
>>  ?subArg), noValue(?subArg
>>  ?predicate) -> (?subTemplate
>>  ?arg)]
>>
>> Sometimes I get desired results, sometimes only a single param is
>> inferred.
>>
>> Are the rules wrong or is this can't be done with monotonic rules?
>>
>>
>> Thanks,
>>
>> Martynas
>>
>


Re: Construct query

2016-09-29 Thread A. Soroka
Did you read the examples in the spec? They are quite illuminative.

https://www.w3.org/TR/2013/REC-sparql11-query-20130321/#construct

---
A. Soroka
The University of Virginia Library

> On Sep 29, 2016, at 4:44 PM, tina sani  wrote:
> 
> I want to know about the Construct query.
> How it differs from Select query
> Is it create a new property/class which is not already in the ontology or
> it just creates new triples.
> I will appreciate if some one come with a simple example. I have searched
> web, but could not grasp it.



Construct query

2016-09-29 Thread tina sani
I want to know about the Construct query.
How it differs from Select query
Is it create a new property/class which is not already in the ontology or
it just creates new triples.
I will appreciate if some one come with a simple example. I have searched
web, but could not grasp it.


Re: SPIN-Fuseki integration

2016-09-29 Thread A. Soroka
DatasetGraph covers the same ground as an RDF Dataset. So you have a default 
graph and many named graphs, each with its own triples. When an update is made, 
it is via methods that work with a single quad at a time. _BUT_ those methods 
can be (always are with Fuseki) used within the boundaries of a transaction, 
which is declared by other methods on DatasetGraph. So at a given moment during 
an update in Fuseki, you will have a bunch of triples sorted into different 
graphs, and you will be calling different add and remove methods. When the 
update is done, a commit method will be called on the DatasetGraph.

So you could hook into the begin method (called to begin a transaction) and the 
add and delete methods (to keep track of what is being changed during the 
transaction/update) and then the commit method (so that you can trigger your 
rules then, using whatever context is appropriate).

---
A. Soroka
The University of Virginia Library

> On Sep 29, 2016, at 12:42 PM, Jason Koh  wrote:
> 
> Thanks for the idea. I think it is great! Though this id due to my lack of
> knowledge, one thing I am curious of is that DatasetGraph wrapper seems to
> be for the entire graph. Does it mean that it runs SPIN inference to the
> entire graph whenever I write something? I may want to apply SPIN partially
> sometimes like applying SPIN on the new triples (not sure if it sounds
> reasonable.)
> 
> I will start looking at it!
> 
> 
> With regards,
> Jason Koh
> cseweb.ucsd.edu/~jbkoh
> 
> On Thu, Sep 29, 2016 at 8:37 AM, A. Soroka  wrote:
> 
>> This seems a lot stronger in the end-- you get the Fuseki integration
>> desired, but this would also be useful outside that context. And the code
>> is going to be rather a lot easier to write. Much of Fuseki's code concerns
>> managing HTTP action, which isn't really of the essence to your goal.
>> 
>> ---
>> A. Soroka
>> The University of Virginia Library
>> 
>>> On Sep 29, 2016, at 11:34 AM, Andy Seaborne  wrote:
>>> 
>>> 
>>> 
>>> On 28/09/16 23:59, Jason Koh wrote:
>>> ...
 Questions:
 1. What is the functions related to SPARQL query processing? I am
>> looking
 at SPARQL_Query.java, ActionSPARQL.java, etc., but this kinda
 reverse-engineering does not work well until now. I will look into the
 JavaDoc more, but I would appreciate if I can get an enlightment here.
>>> 
>>> There is another way to hook in that may be useful.
>>> 
>>> Instead of the HTTP request lifecycle, hook into the transaction
>> lifecycle on the dataset.
>>> 
>>> 
>>> A DatasetGraph wrapper means you can add the functionality to any
>> existing dataset.
>>> 
>>> This is in jena-arq.
>>> 
>>> All Fuseki requests on the data are performed inside a transaction so if
>> you catch a write transaction, and when it commits, trigger SPIN processing.
>>> 
>>> Fuseki uses Jena's assembler mechanism to describe datasets so they can
>> be setup and configured with needing application Java code
>>> 
>>>  Andy
>> 
>> 



Re: SPIN-Fuseki integration

2016-09-29 Thread Jason Koh
Thanks for the idea. I think it is great! Though this id due to my lack of
knowledge, one thing I am curious of is that DatasetGraph wrapper seems to
be for the entire graph. Does it mean that it runs SPIN inference to the
entire graph whenever I write something? I may want to apply SPIN partially
sometimes like applying SPIN on the new triples (not sure if it sounds
reasonable.)

I will start looking at it!


With regards,
Jason Koh
cseweb.ucsd.edu/~jbkoh

On Thu, Sep 29, 2016 at 8:37 AM, A. Soroka  wrote:

> This seems a lot stronger in the end-- you get the Fuseki integration
> desired, but this would also be useful outside that context. And the code
> is going to be rather a lot easier to write. Much of Fuseki's code concerns
> managing HTTP action, which isn't really of the essence to your goal.
>
> ---
> A. Soroka
> The University of Virginia Library
>
> > On Sep 29, 2016, at 11:34 AM, Andy Seaborne  wrote:
> >
> >
> >
> > On 28/09/16 23:59, Jason Koh wrote:
> > ...
> >> Questions:
> >> 1. What is the functions related to SPARQL query processing? I am
> looking
> >> at SPARQL_Query.java, ActionSPARQL.java, etc., but this kinda
> >> reverse-engineering does not work well until now. I will look into the
> >> JavaDoc more, but I would appreciate if I can get an enlightment here.
> >
> > There is another way to hook in that may be useful.
> >
> > Instead of the HTTP request lifecycle, hook into the transaction
> lifecycle on the dataset.
> >
> >
> > A DatasetGraph wrapper means you can add the functionality to any
> existing dataset.
> >
> > This is in jena-arq.
> >
> > All Fuseki requests on the data are performed inside a transaction so if
> you catch a write transaction, and when it commits, trigger SPIN processing.
> >
> > Fuseki uses Jena's assembler mechanism to describe datasets so they can
> be setup and configured with needing application Java code
> >
> >   Andy
>
>


Re: SPIN-Fuseki integration

2016-09-29 Thread A. Soroka
This seems a lot stronger in the end-- you get the Fuseki integration desired, 
but this would also be useful outside that context. And the code is going to be 
rather a lot easier to write. Much of Fuseki's code concerns managing HTTP 
action, which isn't really of the essence to your goal.

---
A. Soroka
The University of Virginia Library

> On Sep 29, 2016, at 11:34 AM, Andy Seaborne  wrote:
> 
> 
> 
> On 28/09/16 23:59, Jason Koh wrote:
> ...
>> Questions:
>> 1. What is the functions related to SPARQL query processing? I am looking
>> at SPARQL_Query.java, ActionSPARQL.java, etc., but this kinda
>> reverse-engineering does not work well until now. I will look into the
>> JavaDoc more, but I would appreciate if I can get an enlightment here.
> 
> There is another way to hook in that may be useful.
> 
> Instead of the HTTP request lifecycle, hook into the transaction lifecycle on 
> the dataset.
> 
> 
> A DatasetGraph wrapper means you can add the functionality to any existing 
> dataset.
> 
> This is in jena-arq.
> 
> All Fuseki requests on the data are performed inside a transaction so if you 
> catch a write transaction, and when it commits, trigger SPIN processing.
> 
> Fuseki uses Jena's assembler mechanism to describe datasets so they can be 
> setup and configured with needing application Java code
> 
>   Andy



Re: SPIN-Fuseki integration

2016-09-29 Thread Andy Seaborne



On 28/09/16 23:59, Jason Koh wrote:
...

Questions:
1. What is the functions related to SPARQL query processing? I am looking
at SPARQL_Query.java, ActionSPARQL.java, etc., but this kinda
reverse-engineering does not work well until now. I will look into the
JavaDoc more, but I would appreciate if I can get an enlightment here.


There is another way to hook in that may be useful.

Instead of the HTTP request lifecycle, hook into the transaction 
lifecycle on the dataset.



A DatasetGraph wrapper means you can add the functionality to any 
existing dataset.


This is in jena-arq.

All Fuseki requests on the data are performed inside a transaction so if 
you catch a write transaction, and when it commits, trigger SPIN processing.


Fuseki uses Jena's assembler mechanism to describe datasets so they can 
be setup and configured with needing application Java code


Andy


Re: filter error in query

2016-09-29 Thread Andy Seaborne



On 29/09/16 13:07, neha gupta wrote:

Thank you Lorenz, yes I am really enjoying learning Jena and also enjoying
this supportive group.
However, still I did not receive any guidance from my earlier question.

*how can we add/sum  data property values (newly entered) with previous
ones?*


See the thread for the first time you asked this around 2016-09-11.

"Calculating numeric values of Data property in Ontology"




On Thu, Sep 29, 2016 at 4:10 AM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:


Ok, happy to hear that it works now. Although it would be interesting to
know what "random changes" you did. Nevertheless, have fun in using Jena.


On 29.09.2016 12:34, neha gupta wrote:

I am sorry Lorenz for late reply. It gives me the now the integer

number. I

do not know even now how, but I made some random changes to the code and

it

shows me the result now.

Kind regards

On Thu, Sep 29, 2016 at 12:33 AM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:


Obviously not, otherwise you wouldn't get a parse exception?! You can't
have a filter outside of the query. See SPARQL specs and/or tutorials.

And that's what we already told you in the other thread.

You know, it's really strange that you do not answer our questions. So
again, how can you get the exception with the literals given that your
query does not compile and thus you can't get to the point where
literals would have been parsed to Java objects?


SELECT  *" +
" WHERE {  ?x rdf:type  ont:Team . ?x ont:team_goal

?goal

. ?x ont:team_wins ?wins}  filter(?goal>10 && ?wins
"filter"

"filter "" at line 1, column 265.*


--
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center









Re: filter error in query

2016-09-29 Thread neha gupta
Thank you Lorenz, yes I am really enjoying learning Jena and also enjoying
this supportive group.
However, still I did not receive any guidance from my earlier question.

*how can we add/sum  data property values (newly entered) with previous
ones?*


On Thu, Sep 29, 2016 at 4:10 AM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> Ok, happy to hear that it works now. Although it would be interesting to
> know what "random changes" you did. Nevertheless, have fun in using Jena.
>
>
> On 29.09.2016 12:34, neha gupta wrote:
> > I am sorry Lorenz for late reply. It gives me the now the integer
> number. I
> > do not know even now how, but I made some random changes to the code and
> it
> > shows me the result now.
> >
> > Kind regards
> >
> > On Thu, Sep 29, 2016 at 12:33 AM, Lorenz B. <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> Obviously not, otherwise you wouldn't get a parse exception?! You can't
> >> have a filter outside of the query. See SPARQL specs and/or tutorials.
> >>
> >> And that's what we already told you in the other thread.
> >>
> >> You know, it's really strange that you do not answer our questions. So
> >> again, how can you get the exception with the literals given that your
> >> query does not compile and thus you can't get to the point where
> >> literals would have been parsed to Java objects?
> >>
> >>> SELECT  *" +
> >>> " WHERE {  ?x rdf:type  ont:Team . ?x ont:team_goal
> >> ?goal
> >>> . ?x ont:team_wins ?wins}  filter(?goal>10 && ?wins >>>
> >>> Is this syntax correct because it gives me error:* Encountered "
> "filter"
> >>> "filter "" at line 1, column 265.*
> >>>
> >> --
> >> Lorenz Bühmann
> >> AKSW group, University of Leipzig
> >> Group: http://aksw.org - semantic web research center
> >>
> >>
>
>


Re: filter error in query

2016-09-29 Thread Lorenz Buehmann
Ok, happy to hear that it works now. Although it would be interesting to
know what "random changes" you did. Nevertheless, have fun in using Jena.


On 29.09.2016 12:34, neha gupta wrote:
> I am sorry Lorenz for late reply. It gives me the now the integer number. I
> do not know even now how, but I made some random changes to the code and it
> shows me the result now.
>
> Kind regards
>
> On Thu, Sep 29, 2016 at 12:33 AM, Lorenz B. <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>> Obviously not, otherwise you wouldn't get a parse exception?! You can't
>> have a filter outside of the query. See SPARQL specs and/or tutorials.
>>
>> And that's what we already told you in the other thread.
>>
>> You know, it's really strange that you do not answer our questions. So
>> again, how can you get the exception with the literals given that your
>> query does not compile and thus you can't get to the point where
>> literals would have been parsed to Java objects?
>>
>>> SELECT  *" +
>>> " WHERE {  ?x rdf:type  ont:Team . ?x ont:team_goal
>> ?goal
>>> . ?x ont:team_wins ?wins}  filter(?goal>10 && ?wins>>
>>> Is this syntax correct because it gives me error:* Encountered " "filter"
>>> "filter "" at line 1, column 265.*
>>>
>> --
>> Lorenz Bühmann
>> AKSW group, University of Leipzig
>> Group: http://aksw.org - semantic web research center
>>
>>



Re: filter error in query

2016-09-29 Thread neha gupta
I am sorry Lorenz for late reply. It gives me the now the integer number. I
do not know even now how, but I made some random changes to the code and it
shows me the result now.

Kind regards

On Thu, Sep 29, 2016 at 12:33 AM, Lorenz B. <
buehm...@informatik.uni-leipzig.de> wrote:

> Obviously not, otherwise you wouldn't get a parse exception?! You can't
> have a filter outside of the query. See SPARQL specs and/or tutorials.
>
> And that's what we already told you in the other thread.
>
> You know, it's really strange that you do not answer our questions. So
> again, how can you get the exception with the literals given that your
> query does not compile and thus you can't get to the point where
> literals would have been parsed to Java objects?
>
> > SELECT  *" +
> > " WHERE {  ?x rdf:type  ont:Team . ?x ont:team_goal
> ?goal
> > . ?x ont:team_wins ?wins}  filter(?goal>10 && ?wins >
> > Is this syntax correct because it gives me error:* Encountered " "filter"
> > "filter "" at line 1, column 265.*
> >
> --
> Lorenz Bühmann
> AKSW group, University of Leipzig
> Group: http://aksw.org - semantic web research center
>
>


Re: filter error in query

2016-09-29 Thread Lorenz B.
Obviously not, otherwise you wouldn't get a parse exception?! You can't
have a filter outside of the query. See SPARQL specs and/or tutorials.

And that's what we already told you in the other thread.

You know, it's really strange that you do not answer our questions. So
again, how can you get the exception with the literals given that your
query does not compile and thus you can't get to the point where
literals would have been parsed to Java objects?

> SELECT  *" +
> " WHERE {  ?x rdf:type  ont:Team . ?x ont:team_goal  ?goal
> . ?x ont:team_wins ?wins}  filter(?goal>10 && ?wins
> Is this syntax correct because it gives me error:* Encountered " "filter"
> "filter "" at line 1, column 265.*
>
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center