Re: Apache Jena rules to find the minimum in a list of data property values

2021-12-05 Thread Luis Enrique Ramos García
Hi dear,

The issue here is the monotonic level of owl, with sparql functions you can
get this information, but with owl based rules, or inference not (in a set
larger than 2).

The point is that to get that the reasoner (or function) should create a
list, order it and extract the first or last element of the list.


Luis

El dom, 5 dic 2021 a las 14:24, Jakub Jałowiec (<
j.jalow...@student.uw.edu.pl>) escribió:

> Thanks, that solves the problem and I'll stick to it for now.
> Nonetheless, is it possible to automatically infer being an instance of the
> hypothetical class "YoungestPerson" ("the person with the lowest foaf:age
> aggregate by house") in Apache Jena as described above? Ideally, I would
> prefer to separate my conceptual/declarative model from raw data
> manipulation using SPARQL. I am new to RDF & ontologies and I am not sure
> to what extent keeping those two is possible and if it is worth to actually
> invest a lot of time into that.
>
> Best regards,
> Jakub
>
> niedz., 5 gru 2021 o 10:12 Lorenz Buehmann <
> buehm...@informatik.uni-leipzig.de> napisał(a):
>
> > Hi,
> >
> >
> > the common pattern in SPARQL is to get the aggregated value in an inner
> > query first, then in the outer query get the entity with the aggregated
> > value:
> >
> > SELECT ?house ?person ?lowestAge {
> >?person foaf:age ?lowestAge .
> >?person covidepid:livesIn ?house .
> >
> >
> > {SELECT ?house (min(?age) as ?lowestAge)
> > WHERE {
> >?person foaf:age ?age .
> >?person covidepid:livesIn ?house .
> > }
> > GROUP BY ?house}
> > }
> >
> >
> >
> > On 03.12.21 02:16, Jakub Jałowiec wrote:
> > > Hi,
> > > I would appreciate any help with the following problem. I have a bunch
> of
> > > (foaf:Persons, myOntology:livesIn, myOntology:Place) triples. I am
> trying
> > > to find the youngest person in each myOntology:Place (i.e. the person
> > with
> > > the earliest value of foaf:age for each myOntology:Place).
> > > What I've tried so far were:
> > > - OWL complex classes (Class Expression Syntax (
> protegeproject.github.io
> > )
> > > <http://protegeproject.github.io/protege/class-expression-syntax/>) -
> > per
> > > my understanding they have too weak expressivity to express aggregates
> > > among other individuals associated with them
> > > - SPARQL query - something along those lines would work fine but I do
> not
> > > know how to retrieve the IRI of the youngest person:
> > >
> > >> SELECT ?house (min(?age) as ?lowestAge)
> > >> WHERE {
> > >>?person foaf:age ?age .
> > >>?person covidepid:livesIn ?house .
> > >> }
> > >> GROUP BY ?house
> > >
> > > I am curious if extraction of the lowest foaf:age value among a group
> of
> > > people could be achieved using Apache Jena rules. From the
> documentation
> > (
> > > https://jena.apache.org/documentation/inference/#rules) it seems to me
> > that
> > > the closest it gets to it is to write my custom built-in function that
> > > would do exactly that. Is that correct?
> > >
> > > Best regards,
> > > Jakub
> > >
> >
>


Re: Apache Jena rules to find the minimum in a list of data property values

2021-12-05 Thread Martynas Jusevičius
You could use the CONSTRUCT query form as rules and augment your model
with the constructed triples. Something like this (untested):

PREFIX  covidepid: <>
PREFIX  foaf: <http://xmlns.com/foaf/0.1/>

CONSTRUCT
  {
?person a covidepid:YoungestPerson .
  }
WHERE
  { SELECT  ?house ?person ?lowestAge
WHERE
  { ?person  foaf:age   ?lowestAge ;
 covidepid:livesIn  ?house
{ SELECT  ?house (MIN(?age) AS ?lowestAge)
  WHERE
{ ?person  foaf:age   ?age ;
   covidepid:livesIn  ?house
}
  GROUP BY ?house
}
  }
  }

Fix the covidepid: namespaces before use.
Execute using QueryExecution::execConstruct:
https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/query/QueryExecution.html#execConstruct(org.apache.jena.rdf.model.Model)

On Sun, Dec 5, 2021 at 2:24 PM Jakub Jałowiec
 wrote:
>
> Thanks, that solves the problem and I'll stick to it for now.
> Nonetheless, is it possible to automatically infer being an instance of the
> hypothetical class "YoungestPerson" ("the person with the lowest foaf:age
> aggregate by house") in Apache Jena as described above? Ideally, I would
> prefer to separate my conceptual/declarative model from raw data
> manipulation using SPARQL. I am new to RDF & ontologies and I am not sure
> to what extent keeping those two is possible and if it is worth to actually
> invest a lot of time into that.
>
> Best regards,
> Jakub
>
> niedz., 5 gru 2021 o 10:12 Lorenz Buehmann <
> buehm...@informatik.uni-leipzig.de> napisał(a):
>
> > Hi,
> >
> >
> > the common pattern in SPARQL is to get the aggregated value in an inner
> > query first, then in the outer query get the entity with the aggregated
> > value:
> >
> > SELECT ?house ?person ?lowestAge {
> >?person foaf:age ?lowestAge .
> >?person covidepid:livesIn ?house .
> >
> >
> > {SELECT ?house (min(?age) as ?lowestAge)
> > WHERE {
> >?person foaf:age ?age .
> >?person covidepid:livesIn ?house .
> > }
> > GROUP BY ?house}
> > }
> >
> >
> >
> > On 03.12.21 02:16, Jakub Jałowiec wrote:
> > > Hi,
> > > I would appreciate any help with the following problem. I have a bunch of
> > > (foaf:Persons, myOntology:livesIn, myOntology:Place) triples. I am trying
> > > to find the youngest person in each myOntology:Place (i.e. the person
> > with
> > > the earliest value of foaf:age for each myOntology:Place).
> > > What I've tried so far were:
> > > - OWL complex classes (Class Expression Syntax (protegeproject.github.io
> > )
> > > <http://protegeproject.github.io/protege/class-expression-syntax/>) -
> > per
> > > my understanding they have too weak expressivity to express aggregates
> > > among other individuals associated with them
> > > - SPARQL query - something along those lines would work fine but I do not
> > > know how to retrieve the IRI of the youngest person:
> > >
> > >> SELECT ?house (min(?age) as ?lowestAge)
> > >> WHERE {
> > >>?person foaf:age ?age .
> > >>?person covidepid:livesIn ?house .
> > >> }
> > >> GROUP BY ?house
> > >
> > > I am curious if extraction of the lowest foaf:age value among a group of
> > > people could be achieved using Apache Jena rules. From the documentation
> > (
> > > https://jena.apache.org/documentation/inference/#rules) it seems to me
> > that
> > > the closest it gets to it is to write my custom built-in function that
> > > would do exactly that. Is that correct?
> > >
> > > Best regards,
> > > Jakub
> > >
> >


Re: Apache Jena rules to find the minimum in a list of data property values

2021-12-05 Thread Jakub Jałowiec
Thanks, that solves the problem and I'll stick to it for now.
Nonetheless, is it possible to automatically infer being an instance of the
hypothetical class "YoungestPerson" ("the person with the lowest foaf:age
aggregate by house") in Apache Jena as described above? Ideally, I would
prefer to separate my conceptual/declarative model from raw data
manipulation using SPARQL. I am new to RDF & ontologies and I am not sure
to what extent keeping those two is possible and if it is worth to actually
invest a lot of time into that.

Best regards,
Jakub

niedz., 5 gru 2021 o 10:12 Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> napisał(a):

> Hi,
>
>
> the common pattern in SPARQL is to get the aggregated value in an inner
> query first, then in the outer query get the entity with the aggregated
> value:
>
> SELECT ?house ?person ?lowestAge {
>?person foaf:age ?lowestAge .
>?person covidepid:livesIn ?house .
>
>
> {SELECT ?house (min(?age) as ?lowestAge)
> WHERE {
>?person foaf:age ?age .
>?person covidepid:livesIn ?house .
> }
> GROUP BY ?house}
> }
>
>
>
> On 03.12.21 02:16, Jakub Jałowiec wrote:
> > Hi,
> > I would appreciate any help with the following problem. I have a bunch of
> > (foaf:Persons, myOntology:livesIn, myOntology:Place) triples. I am trying
> > to find the youngest person in each myOntology:Place (i.e. the person
> with
> > the earliest value of foaf:age for each myOntology:Place).
> > What I've tried so far were:
> > - OWL complex classes (Class Expression Syntax (protegeproject.github.io
> )
> > <http://protegeproject.github.io/protege/class-expression-syntax/>) -
> per
> > my understanding they have too weak expressivity to express aggregates
> > among other individuals associated with them
> > - SPARQL query - something along those lines would work fine but I do not
> > know how to retrieve the IRI of the youngest person:
> >
> >> SELECT ?house (min(?age) as ?lowestAge)
> >> WHERE {
> >>    ?person foaf:age ?age .
> >>?person covidepid:livesIn ?house .
> >> }
> >> GROUP BY ?house
> >
> > I am curious if extraction of the lowest foaf:age value among a group of
> > people could be achieved using Apache Jena rules. From the documentation
> (
> > https://jena.apache.org/documentation/inference/#rules) it seems to me
> that
> > the closest it gets to it is to write my custom built-in function that
> > would do exactly that. Is that correct?
> >
> > Best regards,
> > Jakub
> >
>


Re: Apache Jena rules to find the minimum in a list of data property values

2021-12-05 Thread Lorenz Buehmann

Hi,


the common pattern in SPARQL is to get the aggregated value in an inner 
query first, then in the outer query get the entity with the aggregated 
value:


SELECT ?house ?person ?lowestAge {
  ?person foaf:age ?lowestAge .
  ?person covidepid:livesIn ?house .


{SELECT ?house (min(?age) as ?lowestAge)
WHERE {
  ?person foaf:age ?age .
  ?person covidepid:livesIn ?house .
}
GROUP BY ?house}
}



On 03.12.21 02:16, Jakub Jałowiec wrote:

Hi,
I would appreciate any help with the following problem. I have a bunch of
(foaf:Persons, myOntology:livesIn, myOntology:Place) triples. I am trying
to find the youngest person in each myOntology:Place (i.e. the person with
the earliest value of foaf:age for each myOntology:Place).
What I've tried so far were:
- OWL complex classes (Class Expression Syntax (protegeproject.github.io)
<http://protegeproject.github.io/protege/class-expression-syntax/>) - per
my understanding they have too weak expressivity to express aggregates
among other individuals associated with them
- SPARQL query - something along those lines would work fine but I do not
know how to retrieve the IRI of the youngest person:


SELECT ?house (min(?age) as ?lowestAge)
WHERE {
   ?person foaf:age ?age .
   ?person covidepid:livesIn ?house .
}
GROUP BY ?house


I am curious if extraction of the lowest foaf:age value among a group of
people could be achieved using Apache Jena rules. From the documentation (
https://jena.apache.org/documentation/inference/#rules) it seems to me that
the closest it gets to it is to write my custom built-in function that
would do exactly that. Is that correct?

Best regards,
Jakub



Apache Jena rules to find the minimum in a list of data property values

2021-12-02 Thread Jakub Jałowiec
Hi,
I would appreciate any help with the following problem. I have a bunch of
(foaf:Persons, myOntology:livesIn, myOntology:Place) triples. I am trying
to find the youngest person in each myOntology:Place (i.e. the person with
the earliest value of foaf:age for each myOntology:Place).
What I've tried so far were:
- OWL complex classes (Class Expression Syntax (protegeproject.github.io)
<http://protegeproject.github.io/protege/class-expression-syntax/>) - per
my understanding they have too weak expressivity to express aggregates
among other individuals associated with them
- SPARQL query - something along those lines would work fine but I do not
know how to retrieve the IRI of the youngest person:

> SELECT ?house (min(?age) as ?lowestAge)
> WHERE {
>   ?person foaf:age ?age .
>   ?person covidepid:livesIn ?house .
> }
> GROUP BY ?house


I am curious if extraction of the lowest foaf:age value among a group of
people could be achieved using Apache Jena rules. From the documentation (
https://jena.apache.org/documentation/inference/#rules) it seems to me that
the closest it gets to it is to write my custom built-in function that
would do exactly that. Is that correct?

Best regards,
Jakub


Re: [GenericRuleReasoner] print builtins in forward rules

2021-04-13 Thread Dave Reynolds

Hi Barry,

Yes, the builtins on the LHS of a forward rule will not run until the 
triple patterns match. It's only when there's a binding vector from the 
tree of patterns that it gets submitted to the builtins. Which makes 
sense if you think of LHS builtins as normally being guards.


Dvae

On 13/04/2021 12:00, Nouwt, B. (Barry) wrote:

Hi all, I am working with forward rules for a project and I noticed that the 
print(...) builtins in the LHS of a forward rule only get executed when the 
full LHS matches. I was expecting the LHS to be matched in a per triple/builtin 
manner and so the print(...) builtins get executed until a triple or builtin 
did not match.

Can anyone confirm or deny that this is indeed the way the forwardRETE engine 
works?

Kind regards, Barry
This message may contain information that is not intended for you. If you are 
not the addressee or if this message was sent to you by mistake, you are 
requested to inform the sender and delete the message. TNO accepts no liability 
for the content of this e-mail, for the manner in which you use it and for 
damage of any kind resulting from the risks inherent to the electronic 
transmission of messages.



[GenericRuleReasoner] print builtins in forward rules

2021-04-13 Thread Nouwt, B. (Barry)
Hi all, I am working with forward rules for a project and I noticed that the 
print(...) builtins in the LHS of a forward rule only get executed when the 
full LHS matches. I was expecting the LHS to be matched in a per triple/builtin 
manner and so the print(...) builtins get executed until a triple or builtin 
did not match.

Can anyone confirm or deny that this is indeed the way the forwardRETE engine 
works?

Kind regards, Barry
This message may contain information that is not intended for you. If you are 
not the addressee or if this message was sent to you by mistake, you are 
requested to inform the sender and delete the message. TNO accepts no liability 
for the content of this e-mail, for the manner in which you use it and for 
damage of any kind resulting from the risks inherent to the electronic 
transmission of messages.


Re: RDFXML syntax rules

2021-01-21 Thread Hans-Juergen Rennau
 Harri, one tip which might be of interest to you.
- For analyzing XML files (as well as JSON, CSV and HTML files), XQuery enables 
stupendously compact and simple solutions [1]. 
- For analyzing sets of XML files distributed over the file system (and or the 
web), Foxpath (which extends XQuery) is super convenient [2]. 

In case you want more information, you can contact me in private.
With kind regards,Hans-Jürgen
[1] basex.org/download
[2] https://github.com/hrennau/foxpath

Am Donnerstag, 21. Januar 2021, 10:23:59 MEZ hat Harri Kiiskinen 
 Folgendes geschrieben:  
 
 For a machine readable solution:

There is a Relax NG compact schema file for RDF/XML here:
https://www.w3.org/2013/10/rdfxml.rnc

For validating, you can use jing. You need to translate to schema file 
first from rnc to rng with trang.
https://github.com/relaxng/jing-trang

With trang you can also get XSD schema output.

I personally use Emacs to analyze my RDF/XML files for errors. It 
integrates the above-mentioned Relax NG schema, so I can both browse the 
errors and try different options to fix them.

Harri Kiiskinen

On 21.1.2021 0.39, Andy Seaborne wrote:
> As XML?
> 
> Jena uses the XML parser in the JDK.
> 
> For the defn of RDF/XML on top of XML parsing:
> 
> https://www.w3.org/TR/rdf-syntax-grammar/
> 
>      Andy
> 
> On 20/01/2021 20:27, Dr. Chavdar Ivanov wrote:
>> Hello,
>>
>> When reading a model (RDFXML) Jena correctly reports errors if there 
>> is something not correct in the XML file/data - missing tag or some 
>> space not at the right place, etc.
>> I guess this follows some spec from W3C or else where on XML syntax. I 
>> am looking to find the source and ideally a machine readable 
>> expression of these rules XSD or some other form.
>> Is somebody aware of something existing?
>>
>> Best regards
>> Chavdar
>>

-- 
Tutkijatohtori / post-doctoral researcher
Movie Making Finland: Finnish fiction films as audiovisual big data, 
1907–2017 (MoMaF)
Turun yliopisto / University of Turku
  

Re: RDFXML syntax rules

2021-01-21 Thread Harri Kiiskinen

For a machine readable solution:

There is a Relax NG compact schema file for RDF/XML here:
https://www.w3.org/2013/10/rdfxml.rnc

For validating, you can use jing. You need to translate to schema file 
first from rnc to rng with trang.

https://github.com/relaxng/jing-trang

With trang you can also get XSD schema output.

I personally use Emacs to analyze my RDF/XML files for errors. It 
integrates the above-mentioned Relax NG schema, so I can both browse the 
errors and try different options to fix them.


Harri Kiiskinen

On 21.1.2021 0.39, Andy Seaborne wrote:

As XML?

Jena uses the XML parser in the JDK.

For the defn of RDF/XML on top of XML parsing:

https://www.w3.org/TR/rdf-syntax-grammar/

     Andy

On 20/01/2021 20:27, Dr. Chavdar Ivanov wrote:

Hello,

When reading a model (RDFXML) Jena correctly reports errors if there 
is something not correct in the XML file/data - missing tag or some 
space not at the right place, etc.
I guess this follows some spec from W3C or else where on XML syntax. I 
am looking to find the source and ideally a machine readable 
expression of these rules XSD or some other form.

Is somebody aware of something existing?

Best regards
Chavdar



--
Tutkijatohtori / post-doctoral researcher
Movie Making Finland: Finnish fiction films as audiovisual big data, 
1907–2017 (MoMaF)

Turun yliopisto / University of Turku


Re: RDFXML syntax rules

2021-01-20 Thread Andy Seaborne

As XML?

Jena uses the XML parser in the JDK.

For the defn of RDF/XML on top of XML parsing:

https://www.w3.org/TR/rdf-syntax-grammar/

Andy

On 20/01/2021 20:27, Dr. Chavdar Ivanov wrote:

Hello,

When reading a model (RDFXML) Jena correctly reports errors if there is 
something not correct in the XML file/data - missing tag or some space not at 
the right place, etc.
I guess this follows some spec from W3C or else where on XML syntax. I am 
looking to find the source and ideally a machine readable expression of these 
rules XSD or some other form.
Is somebody aware of something existing?

Best regards
Chavdar
  



RDFXML syntax rules

2021-01-20 Thread Dr. Chavdar Ivanov
Hello,

When reading a model (RDFXML) Jena correctly reports errors if there is 
something not correct in the XML file/data - missing tag or some space not at 
the right place, etc.
I guess this follows some spec from W3C or else where on XML syntax. I am 
looking to find the source and ideally a machine readable expression of these 
rules XSD or some other form.
Is somebody aware of something existing?

Best regards
Chavdar 
 


Re: Add rules at runtime

2020-10-31 Thread Johan Kumps
Fixed!

I now create my dataset as follows in an assembler:

if ( !exactlyOneProperty(root, pLocation) )
throw new AssemblerException(root, "No location given");

String dir = getStringValue(root, pLocation);
Location loc = Location.create(dir);
DatasetGraph dsg = DatabaseMgr.connectDatasetGraph(loc);

if ( root.hasProperty(pUnionDefaultGraph) ) {
Node b = root.getProperty(pUnionDefaultGraph).getObject().asNode();
NodeValue nv = NodeValue.makeNode(b);
if ( nv.isBoolean() )
dsg.getContext().set(TDB2.symUnionDefaultGraph, nv.getBoolean());
else
Log.warn(DatasetAssemblerTDB.class, "Failed to recognize value
for union graph setting (ignored): " + b);
}


RulesReloadingDataset rulesReloadingDataset
= new RulesReloadingDataset(ModelFactory.createInfModel(new
GenericRuleReasoner(new ArrayList()),
ModelFactory.createModelForGraph(dsg.getDefaultGraph(;
return rulesReloadingDataset;


Thank your for your hints!
Johan,

Op za 31 okt. 2020 om 11:03 schreef Johan Kumps :

> Hi,
>
> I managed to create a custom dataset and get it registered. It seems to
> work fine but apparently it is an in memory dataset. Rules get reloaded
> when I change the rule set.
> How should I make sure it is a tdb2 persistent one?
>
> Johan
>
> Op vr 30 okt. 2020 om 23:08 schreef Johan Kumps :
>
>> Barry,
>>
>> Would you mind to share your CustomDatasetAssembler and Fuseki turtle
>> config file?
>> I'm struggling to find out how to make Jena aware of my custom dataset
>> implementation.
>>
>> Thank you very much!
>>
>> Johan,
>>
>> Op vr 30 okt. 2020 om 20:10 schreef Johan Kumps :
>>
>>> Barry,
>>>
>>> Thanks for the pointer. I'll try that out!
>>>
>>> You're right we already attended the same Interconnect call's :). I
>>> emailed you about SparQL+ :)
>>>
>>> Johan,
>>>
>>> Op vr 30 okt. 2020 om 18:35 schreef Nouwt, B. (Barry)
>>> :
>>>
>>>> Hi Johan, I can give some implementation pointers.
>>>>
>>>> We implemented our own dataset:
>>>>
>>>> public class CustomDataset extends DatasetImpl { ... }
>>>>
>>>> And in this dataset we periodically update the rules like this:
>>>>
>>>> public void updateRules(List rules)
>>>> {
>>>> Model m = this.getDefaultModel();
>>>> InfGraph ig = (InfGraph) m.getGraph();
>>>>     Graph rawGraph = ig.getRawGraph();
>>>> Reasoner r = ig.getReasoner();
>>>> if (r instanceof GenericRuleReasoner) {
>>>> GenericRuleReasoner gr = (GenericRuleReasoner) r;
>>>> List oldRules = gr.getRules();
>>>> LOG.trace("Old rules: {}", oldRules);
>>>> if (!oldRules.equals(rules)) {
>>>> LOG.trace("New rules: {}", rules);
>>>> gr.setRules(rules);
>>>> InfModel inf = ModelFactory.createInfModel(gr,
>>>> ModelFactory.createModelForGraph(rawGraph));
>>>> this.setDefaultModel(inf);
>>>> }
>>>> }
>>>>
>>>> Then we use a CustomDatasetAssembler (i.e.
>>>> https://jena.apache.org/documentation/assembler/inside-assemblers.html)
>>>> to configure our dataset using a Fuseki Turtle configuration file:
>>>>
>>>> ...
>>>>
>>>> ex:CustomDataset ja:assembler "org.test.CustomDatasetAssembler" .
>>>>
>>>> ex:dataset rdf:type ex:CustomDataset ;
>>>> ja:defaultGraph ke:infGraph .
>>>>
>>>> ...
>>>>
>>>> This is probably not the ideal way, but it works good enough for our
>>>> non-production environment.
>>>>
>>>> By the way, I think I recognize your name from the InterConnect project.
>>>>
>>>> Kind regards, Barry
>>>>
>>>> -Original Message-
>>>> From: Johan Kumps 
>>>> Sent: zondag 25 oktober 2020 11:47
>>>> To: users@jena.apache.org
>>>> Subject: Re: Add rules at runtime
>>>>
>>>> Hi Barry,
>>>>
>>>> Could you share your code please?
>>>>
>>>> Thanks!
>>>>
>>>> Op di 13 okt. 2020 om 08:30 schreef Nouwt, B. (Barry)
>>>> :
>>>>
>>>> > Hi Johan, you can definitely reload the rules 

Re: Add rules at runtime

2020-10-31 Thread Johan Kumps
Hi,

I managed to create a custom dataset and get it registered. It seems to
work fine but apparently it is an in memory dataset. Rules get reloaded
when I change the rule set.
How should I make sure it is a tdb2 persistent one?

Johan

Op vr 30 okt. 2020 om 23:08 schreef Johan Kumps :

> Barry,
>
> Would you mind to share your CustomDatasetAssembler and Fuseki turtle
> config file?
> I'm struggling to find out how to make Jena aware of my custom dataset
> implementation.
>
> Thank you very much!
>
> Johan,
>
> Op vr 30 okt. 2020 om 20:10 schreef Johan Kumps :
>
>> Barry,
>>
>> Thanks for the pointer. I'll try that out!
>>
>> You're right we already attended the same Interconnect call's :). I
>> emailed you about SparQL+ :)
>>
>> Johan,
>>
>> Op vr 30 okt. 2020 om 18:35 schreef Nouwt, B. (Barry)
>> :
>>
>>> Hi Johan, I can give some implementation pointers.
>>>
>>> We implemented our own dataset:
>>>
>>> public class CustomDataset extends DatasetImpl { ... }
>>>
>>> And in this dataset we periodically update the rules like this:
>>>
>>> public void updateRules(List rules)
>>> {
>>> Model m = this.getDefaultModel();
>>> InfGraph ig = (InfGraph) m.getGraph();
>>> Graph rawGraph = ig.getRawGraph();
>>> Reasoner r = ig.getReasoner();
>>>     if (r instanceof GenericRuleReasoner) {
>>> GenericRuleReasoner gr = (GenericRuleReasoner) r;
>>> List oldRules = gr.getRules();
>>> LOG.trace("Old rules: {}", oldRules);
>>> if (!oldRules.equals(rules)) {
>>> LOG.trace("New rules: {}", rules);
>>> gr.setRules(rules);
>>> InfModel inf = ModelFactory.createInfModel(gr,
>>> ModelFactory.createModelForGraph(rawGraph));
>>> this.setDefaultModel(inf);
>>> }
>>> }
>>>
>>> Then we use a CustomDatasetAssembler (i.e.
>>> https://jena.apache.org/documentation/assembler/inside-assemblers.html)
>>> to configure our dataset using a Fuseki Turtle configuration file:
>>>
>>> ...
>>>
>>> ex:CustomDataset ja:assembler "org.test.CustomDatasetAssembler" .
>>>
>>> ex:dataset rdf:type ex:CustomDataset ;
>>> ja:defaultGraph ke:infGraph .
>>>
>>> ...
>>>
>>> This is probably not the ideal way, but it works good enough for our
>>> non-production environment.
>>>
>>> By the way, I think I recognize your name from the InterConnect project.
>>>
>>> Kind regards, Barry
>>>
>>> -Original Message-
>>> From: Johan Kumps 
>>> Sent: zondag 25 oktober 2020 11:47
>>> To: users@jena.apache.org
>>> Subject: Re: Add rules at runtime
>>>
>>> Hi Barry,
>>>
>>> Could you share your code please?
>>>
>>> Thanks!
>>>
>>> Op di 13 okt. 2020 om 08:30 schreef Nouwt, B. (Barry)
>>> :
>>>
>>> > Hi Johan, you can definitely reload the rules in Apache Jena Fuseki,
>>> > but it requires programming. I did it by creating a custom Dataset
>>> > implementation (which I configured using an Assembler configuration
>>> > file) that periodically reloads the rules, but that might not be the
>>> easiest way.
>>> > Regards, Barry
>>> >
>>> > -Original Message-
>>> > From: Johan Kumps 
>>> > Sent: maandag 12 oktober 2020 22:16
>>> > To: users@jena.apache.org
>>> > Subject: Re: Add rules at runtime
>>> >
>>> > Hi,
>>> >
>>> > I understand that within Jena rules and data are stored separately but
>>> > the question is whether there is a possibility to reload rules in the
>>> > given file. If so it would be possible to reload the rule set without
>>> > having to restart the server.
>>> > Any ideas?
>>> >
>>> > Johan,
>>> >
>>> > Op ma 5 okt. 2020 om 14:12 schreef Nouwt, B. (Barry)
>>> > :
>>> >
>>> > > Hi Johan,
>>> > >
>>> > > I do not think Apache Jena Fuseki supports uploading a rule file as
>>> > > you would do with data. Apache Jena rules (
>>> > > https://jena.apache.org/documentation/inference/) can onl

Re: Add rules at runtime

2020-10-30 Thread Johan Kumps
Barry,

Would you mind to share your CustomDatasetAssembler and Fuseki turtle
config file?
I'm struggling to find out how to make Jena aware of my custom dataset
implementation.

Thank you very much!

Johan,

Op vr 30 okt. 2020 om 20:10 schreef Johan Kumps :

> Barry,
>
> Thanks for the pointer. I'll try that out!
>
> You're right we already attended the same Interconnect call's :). I
> emailed you about SparQL+ :)
>
> Johan,
>
> Op vr 30 okt. 2020 om 18:35 schreef Nouwt, B. (Barry)
> :
>
>> Hi Johan, I can give some implementation pointers.
>>
>> We implemented our own dataset:
>>
>> public class CustomDataset extends DatasetImpl { ... }
>>
>> And in this dataset we periodically update the rules like this:
>>
>> public void updateRules(List rules)
>> {
>> Model m = this.getDefaultModel();
>> InfGraph ig = (InfGraph) m.getGraph();
>> Graph rawGraph = ig.getRawGraph();
>> Reasoner r = ig.getReasoner();
>> if (r instanceof GenericRuleReasoner) {
>> GenericRuleReasoner gr = (GenericRuleReasoner) r;
>> List oldRules = gr.getRules();
>> LOG.trace("Old rules: {}", oldRules);
>> if (!oldRules.equals(rules)) {
>> LOG.trace("New rules: {}", rules);
>> gr.setRules(rules);
>> InfModel inf = ModelFactory.createInfModel(gr,
>> ModelFactory.createModelForGraph(rawGraph));
>> this.setDefaultModel(inf);
>> }
>> }
>>
>> Then we use a CustomDatasetAssembler (i.e.
>> https://jena.apache.org/documentation/assembler/inside-assemblers.html)
>> to configure our dataset using a Fuseki Turtle configuration file:
>>
>> ...
>>
>> ex:CustomDataset ja:assembler "org.test.CustomDatasetAssembler" .
>>
>> ex:dataset rdf:type ex:CustomDataset ;
>> ja:defaultGraph ke:infGraph .
>>
>> ...
>>
>> This is probably not the ideal way, but it works good enough for our
>> non-production environment.
>>
>> By the way, I think I recognize your name from the InterConnect project.
>>
>> Kind regards, Barry
>>
>> -Original Message-
>> From: Johan Kumps 
>> Sent: zondag 25 oktober 2020 11:47
>> To: users@jena.apache.org
>> Subject: Re: Add rules at runtime
>>
>> Hi Barry,
>>
>> Could you share your code please?
>>
>> Thanks!
>>
>> Op di 13 okt. 2020 om 08:30 schreef Nouwt, B. (Barry)
>> :
>>
>> > Hi Johan, you can definitely reload the rules in Apache Jena Fuseki,
>> > but it requires programming. I did it by creating a custom Dataset
>> > implementation (which I configured using an Assembler configuration
>> > file) that periodically reloads the rules, but that might not be the
>> easiest way.
>> > Regards, Barry
>> >
>> > -Original Message-
>> > From: Johan Kumps 
>> > Sent: maandag 12 oktober 2020 22:16
>> > To: users@jena.apache.org
>> > Subject: Re: Add rules at runtime
>> >
>> > Hi,
>> >
>> > I understand that within Jena rules and data are stored separately but
>> > the question is whether there is a possibility to reload rules in the
>> > given file. If so it would be possible to reload the rule set without
>> > having to restart the server.
>> > Any ideas?
>> >
>> > Johan,
>> >
>> > Op ma 5 okt. 2020 om 14:12 schreef Nouwt, B. (Barry)
>> > :
>> >
>> > > Hi Johan,
>> > >
>> > > I do not think Apache Jena Fuseki supports uploading a rule file as
>> > > you would do with data. Apache Jena rules (
>> > > https://jena.apache.org/documentation/inference/) can only be set as
>> > > part of the configuration of a dataset, I think.
>> > >
>> > > However, if you use another type of constraints/rules (i.e. SWRL or
>> > > OWL Restrictions), you can maybe upload those as part of your data
>> > > (as they are part of you ontology, I think). If you then use a
>> > > reasoner that supports those constraints/rules (Pellet maybe?), it
>> > > will probably take them into account.
>> > >
>> > > Hope this helps!
>> > >
>> > > Regards, Barry
>> > >
>> > > -Original Message-
>> > > From: Johan Kumps 
>> > > Sent: maandag 5 oktober 2020 13:37
>> > > To: users@jena.apache.org
>> > > Subject: Add rules at runtime
>> > >
>> > > Hi all,
>> > >
>> > > Is it possible to add rules to Jena at runtime or is it only
>> > > possible to add rules via a file and restart the server?
>> > >
>> > > It would be very nice if you could upload a rule the same way as you
>> > > can do to add data to a dataset.
>> > >
>> > > Kind regards,
>> > > Johan,
>> > > This message may contain information that is not intended for you.
>> > > If you are not the addressee or if this message was sent to you by
>> > > mistake, you are requested to inform the sender and delete the
>> > > message. TNO accepts no liability for the content of this e-mail,
>> > > for the manner in which you use it and for damage of any kind
>> > > resulting from the risks inherent to the electronic transmission of
>> messages.
>> > >
>> >
>>
>


Re: Add rules at runtime

2020-10-30 Thread Johan Kumps
Barry,

Thanks for the pointer. I'll try that out!

You're right we already attended the same Interconnect call's :). I emailed
you about SparQL+ :)

Johan,

Op vr 30 okt. 2020 om 18:35 schreef Nouwt, B. (Barry)
:

> Hi Johan, I can give some implementation pointers.
>
> We implemented our own dataset:
>
> public class CustomDataset extends DatasetImpl { ... }
>
> And in this dataset we periodically update the rules like this:
>
> public void updateRules(List rules)
> {
> Model m = this.getDefaultModel();
> InfGraph ig = (InfGraph) m.getGraph();
> Graph rawGraph = ig.getRawGraph();
> Reasoner r = ig.getReasoner();
> if (r instanceof GenericRuleReasoner) {
> GenericRuleReasoner gr = (GenericRuleReasoner) r;
>     List oldRules = gr.getRules();
> LOG.trace("Old rules: {}", oldRules);
>     if (!oldRules.equals(rules)) {
>     LOG.trace("New rules: {}", rules);
> gr.setRules(rules);
> InfModel inf = ModelFactory.createInfModel(gr,
> ModelFactory.createModelForGraph(rawGraph));
> this.setDefaultModel(inf);
> }
> }
>
> Then we use a CustomDatasetAssembler (i.e.
> https://jena.apache.org/documentation/assembler/inside-assemblers.html)
> to configure our dataset using a Fuseki Turtle configuration file:
>
> ...
>
> ex:CustomDataset ja:assembler "org.test.CustomDatasetAssembler" .
>
> ex:dataset rdf:type ex:CustomDataset ;
> ja:defaultGraph ke:infGraph .
>
> ...
>
> This is probably not the ideal way, but it works good enough for our
> non-production environment.
>
> By the way, I think I recognize your name from the InterConnect project.
>
> Kind regards, Barry
>
> -Original Message-
> From: Johan Kumps 
> Sent: zondag 25 oktober 2020 11:47
> To: users@jena.apache.org
> Subject: Re: Add rules at runtime
>
> Hi Barry,
>
> Could you share your code please?
>
> Thanks!
>
> Op di 13 okt. 2020 om 08:30 schreef Nouwt, B. (Barry)
> :
>
> > Hi Johan, you can definitely reload the rules in Apache Jena Fuseki,
> > but it requires programming. I did it by creating a custom Dataset
> > implementation (which I configured using an Assembler configuration
> > file) that periodically reloads the rules, but that might not be the
> easiest way.
> > Regards, Barry
> >
> > -Original Message-
> > From: Johan Kumps 
> > Sent: maandag 12 oktober 2020 22:16
> > To: users@jena.apache.org
> > Subject: Re: Add rules at runtime
> >
> > Hi,
> >
> > I understand that within Jena rules and data are stored separately but
> > the question is whether there is a possibility to reload rules in the
> > given file. If so it would be possible to reload the rule set without
> > having to restart the server.
> > Any ideas?
> >
> > Johan,
> >
> > Op ma 5 okt. 2020 om 14:12 schreef Nouwt, B. (Barry)
> > :
> >
> > > Hi Johan,
> > >
> > > I do not think Apache Jena Fuseki supports uploading a rule file as
> > > you would do with data. Apache Jena rules (
> > > https://jena.apache.org/documentation/inference/) can only be set as
> > > part of the configuration of a dataset, I think.
> > >
> > > However, if you use another type of constraints/rules (i.e. SWRL or
> > > OWL Restrictions), you can maybe upload those as part of your data
> > > (as they are part of you ontology, I think). If you then use a
> > > reasoner that supports those constraints/rules (Pellet maybe?), it
> > > will probably take them into account.
> > >
> > > Hope this helps!
> > >
> > > Regards, Barry
> > >
> > > -Original Message-
> > > From: Johan Kumps 
> > > Sent: maandag 5 oktober 2020 13:37
> > > To: users@jena.apache.org
> > > Subject: Add rules at runtime
> > >
> > > Hi all,
> > >
> > > Is it possible to add rules to Jena at runtime or is it only
> > > possible to add rules via a file and restart the server?
> > >
> > > It would be very nice if you could upload a rule the same way as you
> > > can do to add data to a dataset.
> > >
> > > Kind regards,
> > > Johan,
> > > This message may contain information that is not intended for you.
> > > If you are not the addressee or if this message was sent to you by
> > > mistake, you are requested to inform the sender and delete the
> > > message. TNO accepts no liability for the content of this e-mail,
> > > for the manner in which you use it and for damage of any kind
> > > resulting from the risks inherent to the electronic transmission of
> messages.
> > >
> >
>


RE: Add rules at runtime

2020-10-30 Thread Nouwt, B. (Barry)
Hi Johan, I can give some implementation pointers.

We implemented our own dataset:

public class CustomDataset extends DatasetImpl { ... }

And in this dataset we periodically update the rules like this:

public void updateRules(List rules)
{
Model m = this.getDefaultModel();
InfGraph ig = (InfGraph) m.getGraph();
Graph rawGraph = ig.getRawGraph();
Reasoner r = ig.getReasoner();
if (r instanceof GenericRuleReasoner) {
GenericRuleReasoner gr = (GenericRuleReasoner) r;
List oldRules = gr.getRules();
LOG.trace("Old rules: {}", oldRules);
if (!oldRules.equals(rules)) {
LOG.trace("New rules: {}", rules);
    gr.setRules(rules);
InfModel inf = ModelFactory.createInfModel(gr, 
ModelFactory.createModelForGraph(rawGraph));
this.setDefaultModel(inf);
}
}

Then we use a CustomDatasetAssembler (i.e. 
https://jena.apache.org/documentation/assembler/inside-assemblers.html) to 
configure our dataset using a Fuseki Turtle configuration file:

...

ex:CustomDataset ja:assembler "org.test.CustomDatasetAssembler" .

ex:dataset rdf:type ex:CustomDataset ;
ja:defaultGraph ke:infGraph .

...

This is probably not the ideal way, but it works good enough for our 
non-production environment.

By the way, I think I recognize your name from the InterConnect project.

Kind regards, Barry

-Original Message-
From: Johan Kumps  
Sent: zondag 25 oktober 2020 11:47
To: users@jena.apache.org
Subject: Re: Add rules at runtime

Hi Barry,

Could you share your code please?

Thanks!

Op di 13 okt. 2020 om 08:30 schreef Nouwt, B. (Barry)
:

> Hi Johan, you can definitely reload the rules in Apache Jena Fuseki, 
> but it requires programming. I did it by creating a custom Dataset 
> implementation (which I configured using an Assembler configuration 
> file) that periodically reloads the rules, but that might not be the easiest 
> way.
> Regards, Barry
>
> -Original Message-
> From: Johan Kumps 
> Sent: maandag 12 oktober 2020 22:16
> To: users@jena.apache.org
> Subject: Re: Add rules at runtime
>
> Hi,
>
> I understand that within Jena rules and data are stored separately but 
> the question is whether there is a possibility to reload rules in the 
> given file. If so it would be possible to reload the rule set without 
> having to restart the server.
> Any ideas?
>
> Johan,
>
> Op ma 5 okt. 2020 om 14:12 schreef Nouwt, B. (Barry)
> :
>
> > Hi Johan,
> >
> > I do not think Apache Jena Fuseki supports uploading a rule file as 
> > you would do with data. Apache Jena rules (
> > https://jena.apache.org/documentation/inference/) can only be set as 
> > part of the configuration of a dataset, I think.
> >
> > However, if you use another type of constraints/rules (i.e. SWRL or 
> > OWL Restrictions), you can maybe upload those as part of your data 
> > (as they are part of you ontology, I think). If you then use a 
> > reasoner that supports those constraints/rules (Pellet maybe?), it 
> > will probably take them into account.
> >
> > Hope this helps!
> >
> > Regards, Barry
> >
> > -Original Message-
> > From: Johan Kumps 
> > Sent: maandag 5 oktober 2020 13:37
> > To: users@jena.apache.org
> > Subject: Add rules at runtime
> >
> > Hi all,
> >
> > Is it possible to add rules to Jena at runtime or is it only 
> > possible to add rules via a file and restart the server?
> >
> > It would be very nice if you could upload a rule the same way as you 
> > can do to add data to a dataset.
> >
> > Kind regards,
> > Johan,
> > This message may contain information that is not intended for you. 
> > If you are not the addressee or if this message was sent to you by 
> > mistake, you are requested to inform the sender and delete the 
> > message. TNO accepts no liability for the content of this e-mail, 
> > for the manner in which you use it and for damage of any kind 
> > resulting from the risks inherent to the electronic transmission of 
> > messages.
> >
>


Re: Add rules at runtime

2020-10-25 Thread Johan Kumps
Hi Barry,

Could you share your code please?

Thanks!

Op di 13 okt. 2020 om 08:30 schreef Nouwt, B. (Barry)
:

> Hi Johan, you can definitely reload the rules in Apache Jena Fuseki, but
> it requires programming. I did it by creating a custom Dataset
> implementation (which I configured using an Assembler configuration file)
> that periodically reloads the rules, but that might not be the easiest way.
> Regards, Barry
>
> -Original Message-
> From: Johan Kumps 
> Sent: maandag 12 oktober 2020 22:16
> To: users@jena.apache.org
> Subject: Re: Add rules at runtime
>
> Hi,
>
> I understand that within Jena rules and data are stored separately but the
> question is whether there is a possibility to reload rules in the given
> file. If so it would be possible to reload the rule set without having to
> restart the server.
> Any ideas?
>
> Johan,
>
> Op ma 5 okt. 2020 om 14:12 schreef Nouwt, B. (Barry)
> :
>
> > Hi Johan,
> >
> > I do not think Apache Jena Fuseki supports uploading a rule file as
> > you would do with data. Apache Jena rules (
> > https://jena.apache.org/documentation/inference/) can only be set as
> > part of the configuration of a dataset, I think.
> >
> > However, if you use another type of constraints/rules (i.e. SWRL or
> > OWL Restrictions), you can maybe upload those as part of your data (as
> > they are part of you ontology, I think). If you then use a reasoner
> > that supports those constraints/rules (Pellet maybe?), it will
> > probably take them into account.
> >
> > Hope this helps!
> >
> > Regards, Barry
> >
> > -Original Message-
> > From: Johan Kumps 
> > Sent: maandag 5 oktober 2020 13:37
> > To: users@jena.apache.org
> > Subject: Add rules at runtime
> >
> > Hi all,
> >
> > Is it possible to add rules to Jena at runtime or is it only possible
> > to add rules via a file and restart the server?
> >
> > It would be very nice if you could upload a rule the same way as you
> > can do to add data to a dataset.
> >
> > Kind regards,
> > Johan,
> > This message may contain information that is not intended for you. If
> > you are not the addressee or if this message was sent to you by
> > mistake, you are requested to inform the sender and delete the
> > message. TNO accepts no liability for the content of this e-mail, for
> > the manner in which you use it and for damage of any kind resulting
> > from the risks inherent to the electronic transmission of messages.
> >
>


RE: Add rules at runtime

2020-10-12 Thread Nouwt, B. (Barry)
Hi Johan, you can definitely reload the rules in Apache Jena Fuseki, but it 
requires programming. I did it by creating a custom Dataset implementation 
(which I configured using an Assembler configuration file) that periodically 
reloads the rules, but that might not be the easiest way. Regards, Barry

-Original Message-
From: Johan Kumps  
Sent: maandag 12 oktober 2020 22:16
To: users@jena.apache.org
Subject: Re: Add rules at runtime

Hi,

I understand that within Jena rules and data are stored separately but the 
question is whether there is a possibility to reload rules in the given file. 
If so it would be possible to reload the rule set without having to restart the 
server.
Any ideas?

Johan,

Op ma 5 okt. 2020 om 14:12 schreef Nouwt, B. (Barry)
:

> Hi Johan,
>
> I do not think Apache Jena Fuseki supports uploading a rule file as 
> you would do with data. Apache Jena rules (
> https://jena.apache.org/documentation/inference/) can only be set as 
> part of the configuration of a dataset, I think.
>
> However, if you use another type of constraints/rules (i.e. SWRL or 
> OWL Restrictions), you can maybe upload those as part of your data (as 
> they are part of you ontology, I think). If you then use a reasoner 
> that supports those constraints/rules (Pellet maybe?), it will 
> probably take them into account.
>
> Hope this helps!
>
> Regards, Barry
>
> -Original Message-
> From: Johan Kumps 
> Sent: maandag 5 oktober 2020 13:37
> To: users@jena.apache.org
> Subject: Add rules at runtime
>
> Hi all,
>
> Is it possible to add rules to Jena at runtime or is it only possible 
> to add rules via a file and restart the server?
>
> It would be very nice if you could upload a rule the same way as you 
> can do to add data to a dataset.
>
> Kind regards,
> Johan,
> This message may contain information that is not intended for you. If 
> you are not the addressee or if this message was sent to you by 
> mistake, you are requested to inform the sender and delete the 
> message. TNO accepts no liability for the content of this e-mail, for 
> the manner in which you use it and for damage of any kind resulting 
> from the risks inherent to the electronic transmission of messages.
>


Re: Add rules at runtime

2020-10-12 Thread Johan Kumps
Hi,

I understand that within Jena rules and data are stored separately but the
question is whether there is a possibility to reload rules in the given
file. If so it would be possible to reload the rule set without having to
restart the server.
Any ideas?

Johan,

Op ma 5 okt. 2020 om 14:12 schreef Nouwt, B. (Barry)
:

> Hi Johan,
>
> I do not think Apache Jena Fuseki supports uploading a rule file as you
> would do with data. Apache Jena rules (
> https://jena.apache.org/documentation/inference/) can only be set as part
> of the configuration of a dataset, I think.
>
> However, if you use another type of constraints/rules (i.e. SWRL or OWL
> Restrictions), you can maybe upload those as part of your data (as they are
> part of you ontology, I think). If you then use a reasoner that supports
> those constraints/rules (Pellet maybe?), it will probably take them into
> account.
>
> Hope this helps!
>
> Regards, Barry
>
> -Original Message-
> From: Johan Kumps 
> Sent: maandag 5 oktober 2020 13:37
> To: users@jena.apache.org
> Subject: Add rules at runtime
>
> Hi all,
>
> Is it possible to add rules to Jena at runtime or is it only possible to
> add rules via a file and restart the server?
>
> It would be very nice if you could upload a rule the same way as you can
> do to add data to a dataset.
>
> Kind regards,
> Johan,
> This message may contain information that is not intended for you. If you
> are not the addressee or if this message was sent to you by mistake, you
> are requested to inform the sender and delete the message. TNO accepts no
> liability for the content of this e-mail, for the manner in which you use
> it and for damage of any kind resulting from the risks inherent to the
> electronic transmission of messages.
>


Re: My own rules in Jena Fuseki

2020-10-12 Thread Marcelo Machado
I used "ja:rules" and "ja:ruleSet" instead of "ja:rule" and I could create
a repository with no error.

However, my rules don't work. I think that at least triples from OWLMicro
should be in the repository. Therefore, I think the problem is in "@include
" .


At.te,

Marcelo de Oliveira Costa Machado


Em seg., 12 de out. de 2020 às 06:30, Marcelo Machado <
marcelo.oc.mach...@gmail.com> escreveu:

> I don't know what is going on anymore =(
>
> First, It is important to note that I am reading the rule content from a
> file that I already tested using "ja:rulesFrom", thus I believe the
> syntax inside is ok. I mean, there are no problems like you mentioned about
> the columns (it was a copy and paste problem).
>
> Now I am using """ to enclose the rules. So my code is as follows:
>
> :model_inf a ja:InfModel ;
> ja:baseModel :tdbGraph ;
> ja:reasoner [
> ja:reasonerURL <${reasonerURL}> ;
> ja:rule """
> ${rules}
> """ ;
> ]
> .
>
> And ${rules} has the file content (that has more than one rules):
>
> #-*-mode: conf-unix-*-
> @prefix time: <http://www.w3.org/2006/time#>
> @include 
>
> -> table(owl:sameAs).
>
>
> #---
> # Equality
>
> #---
>
> sameAs_symmetry:
> (?x owl:sameAs ?y)
> -> (?y owl:sameAs ?x).
>
> sameAs_transitivity:
> (?x owl:sameAs ?y)
> (?y owl:sameAs ?z)
> -> (?x owl:sameAs ?x).
>
> sameAs_Thing1:
> -> [(?x rdf:type owl:Thing) <- (?x owl:sameAs ?y)].
>
> sameAs_Thing2:
> -> [(?x owl:sameAs ?x) <- (?x rdf:type owl:Thing)].
>
> The error persists expecting '(':
>
> 06:23:01 WARN  Admin   :: [4] RC = 500 : caught: Expected '(' at
> start of clause, found @prefix
>
> At '#-*-mode: conf-unix-*- @prefix '
>
> org.apache.jena.assembler.exceptions.AssemblerException: caught: Expected
> '(' at start of clause, found @prefix
>
> At '#-*-mode: conf-unix-*- @prefix '
>
> at
> org.apache.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.openBySpecificType(AssemblerGroup.java:165)
> ~[fuseki-server.jar:3.17.0-SNAPSHOT]
>
> at
> org.apache.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.open(AssemblerGroup.java:144)
> ~[fuseki-server.jar:3.17.0-SNAPSHOT]
>
> ...
>
>
> FYI I am using this version:
> https://repository.apache.org/content/groups/snapshots/org/apache/jena/apache-jena-fuseki/3.17.0-SNAPSHOT/apache-jena-fuseki-3.17.0-20201005.074744-28.tar.gz
>
> At.te,
>
> Marcelo de Oliveira Costa Machado
>
>
> Em seg., 12 de out. de 2020 às 05:34, Andy Seaborne 
> escreveu:
>
>>
>>
>> On 12/10/2020 01:02, Marcelo Machado wrote:
>> > Thank you Andy, however the error persists.
>> >
>> > Let me send you a part of the data I'm trying to upload:
>> >
>> > :model_inf a ja:InfModel ;
>> >  ja:baseModel :tdbGraph ;
>> >  ja:reasoner [
>> >  ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
>> >  ja:rule "[
>> >  #-*-mode: conf-unix-*-
>> >  @prefix time: <http://www.w3.org/2006/time#>
>> >  @include 
>> >
>> >  -> table(owl:sameAs).
>> >
>> >
>> >
>> #---
>> >  # Equality
>> >
>> >
>> #---
>> >
>> >  sameAs_symmetry:
>> >  (?x owl:sameAs ?y)
>> >  -> (?y owl:sameAs ?x) .
>> >  ]";
>> > ]
>> > .
>>
>> There are a couple of things wrong with the syntax:
>>
>>
>> 1/ Use """ to enclose the rules because it is a multiple line string in
>> Turtle.
>>
>> 2/ Comments in rules are # in column 1 and the
>> "# Equality" and "#-*-mode: conf-unix-*-" are not in col 1.
>>
>> 3/ ] go round a single rule
>>
>> this works for me:
>>
>> = Extract 
>>   ja:reasoner [
>>  ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
>>  ja:rule """
>>  @prefix time: <http://www.w3.org/2006/time#>
>>  @include 
>>
>>  -> table(owl:sam

Re: My own rules in Jena Fuseki

2020-10-12 Thread Marcelo Machado
I don't know what is going on anymore =(

First, It is important to note that I am reading the rule content from a
file that I already tested using "ja:rulesFrom", thus I believe the
syntax inside is ok. I mean, there are no problems like you mentioned about
the columns (it was a copy and paste problem).

Now I am using """ to enclose the rules. So my code is as follows:

:model_inf a ja:InfModel ;
ja:baseModel :tdbGraph ;
ja:reasoner [
ja:reasonerURL <${reasonerURL}> ;
ja:rule """
${rules}
""" ;
]
.

And ${rules} has the file content (that has more than one rules):

#-*-mode: conf-unix-*-
@prefix time: <http://www.w3.org/2006/time#>
@include 

-> table(owl:sameAs).

#---
# Equality
#---

sameAs_symmetry:
(?x owl:sameAs ?y)
-> (?y owl:sameAs ?x).

sameAs_transitivity:
(?x owl:sameAs ?y)
(?y owl:sameAs ?z)
-> (?x owl:sameAs ?x).

sameAs_Thing1:
-> [(?x rdf:type owl:Thing) <- (?x owl:sameAs ?y)].

sameAs_Thing2:
-> [(?x owl:sameAs ?x) <- (?x rdf:type owl:Thing)].

The error persists expecting '(':

06:23:01 WARN  Admin   :: [4] RC = 500 : caught: Expected '(' at
start of clause, found @prefix

At '#-*-mode: conf-unix-*- @prefix '

org.apache.jena.assembler.exceptions.AssemblerException: caught: Expected
'(' at start of clause, found @prefix

At '#-*-mode: conf-unix-*- @prefix '

at
org.apache.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.openBySpecificType(AssemblerGroup.java:165)
~[fuseki-server.jar:3.17.0-SNAPSHOT]

at
org.apache.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.open(AssemblerGroup.java:144)
~[fuseki-server.jar:3.17.0-SNAPSHOT]

...


FYI I am using this version:
https://repository.apache.org/content/groups/snapshots/org/apache/jena/apache-jena-fuseki/3.17.0-SNAPSHOT/apache-jena-fuseki-3.17.0-20201005.074744-28.tar.gz

At.te,

Marcelo de Oliveira Costa Machado


Em seg., 12 de out. de 2020 às 05:34, Andy Seaborne 
escreveu:

>
>
> On 12/10/2020 01:02, Marcelo Machado wrote:
> > Thank you Andy, however the error persists.
> >
> > Let me send you a part of the data I'm trying to upload:
> >
> > :model_inf a ja:InfModel ;
> >  ja:baseModel :tdbGraph ;
> >  ja:reasoner [
> >  ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
> >  ja:rule "[
> >  #-*-mode: conf-unix-*-
> >  @prefix time: <http://www.w3.org/2006/time#>
> >  @include 
> >
> >  -> table(owl:sameAs).
> >
> >
> >
> #---
> >  # Equality
> >
> >
> #---
> >
> >  sameAs_symmetry:
> >  (?x owl:sameAs ?y)
> >  -> (?y owl:sameAs ?x) .
> >  ]";
> > ]
> > .
>
> There are a couple of things wrong with the syntax:
>
>
> 1/ Use """ to enclose the rules because it is a multiple line string in
> Turtle.
>
> 2/ Comments in rules are # in column 1 and the
> "# Equality" and "#-*-mode: conf-unix-*-" are not in col 1.
>
> 3/ ] go round a single rule
>
> this works for me:
>
> = Extract 
>   ja:reasoner [
>  ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
>  ja:rule """
>  @prefix time: <http://www.w3.org/2006/time#>
>  @include 
>
>  -> table(owl:sameAs) .
>
> # Equality
>  [sameAsSymmetry: (?x owl:sameAs ?y) -> (?y owl:sameAs ?x) ]
>
>  """;
> ]
> .
> ==
>
>  Andy
>
>
> >
> > The error:
> >
> > 20:52:05 WARN  Admin   :: [2] RC = 500 : caught: Expected '(' at
> > start of clause, found @prefix
> >
> > At '[ #-*-mode: conf-unix-*- @prefix '
> >
> > org.apache.jena.assembler.exceptions.AssemblerException: caught: Expected
> > '(' at start of clause, found @prefix
> >
> > At '[ #-*-mode: conf-unix-*- @prefix '
> >
> > at
> >
> org.apache.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.openBySpecificType(AssemblerGroup.java:165)
> > ~[fuseki-server.jar:3.17.0-SNAPSHOT]
> >
> >
> > At.te,
> >
> > Marcelo de Oliveira Costa Machado
> >
> >
> > Em dom., 11 de out. de 2020 às 07:52, Andy

Re: My own rules in Jena Fuseki

2020-10-12 Thread Andy Seaborne




On 12/10/2020 01:02, Marcelo Machado wrote:

Thank you Andy, however the error persists.

Let me send you a part of the data I'm trying to upload:

:model_inf a ja:InfModel ;
 ja:baseModel :tdbGraph ;
 ja:reasoner [
 ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
 ja:rule "[
 #-*-mode: conf-unix-*-
 @prefix time: <http://www.w3.org/2006/time#>
 @include 

 -> table(owl:sameAs).


#---
 # Equality

#---

 sameAs_symmetry:
 (?x owl:sameAs ?y)
 -> (?y owl:sameAs ?x) .
 ]";
]
.


There are a couple of things wrong with the syntax:


1/ Use """ to enclose the rules because it is a multiple line string in 
Turtle.


2/ Comments in rules are # in column 1 and the
"# Equality" and "#-*-mode: conf-unix-*-" are not in col 1.

3/ ] go round a single rule

this works for me:

= Extract 
 ja:reasoner [
ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
ja:rule """
@prefix time: <http://www.w3.org/2006/time#>
@include 

-> table(owl:sameAs) .

# Equality
[sameAsSymmetry: (?x owl:sameAs ?y) -> (?y owl:sameAs ?x) ]

""";
]
.
==

Andy




The error:

20:52:05 WARN  Admin   :: [2] RC = 500 : caught: Expected '(' at
start of clause, found @prefix

At '[ #-*-mode: conf-unix-*- @prefix '

org.apache.jena.assembler.exceptions.AssemblerException: caught: Expected
'(' at start of clause, found @prefix

At '[ #-*-mode: conf-unix-*- @prefix '

at
org.apache.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.openBySpecificType(AssemblerGroup.java:165)
~[fuseki-server.jar:3.17.0-SNAPSHOT]


At.te,

Marcelo de Oliveira Costa Machado


Em dom., 11 de out. de 2020 às 07:52, Andy Seaborne 
escreveu:




On 09/10/2020 18:42, Marcelo Machado wrote:

I just downloaded the binary distribution of Fuseki2 and used the
./fuseki_server command to start a server. But I will get the development
build.


Build ready:


https://repository.apache.org/content/groups/snapshots/org/apache/jena/apache-jena-fuseki/3.17.0-SNAPSHOT/

look for the latest

At least dated:

Sun Oct 11

apache-jena-fuseki-3.17.0-20201011




Just pointing out, I believe that the problem is not only with prefix but
with any directives other than the rules, for example, @include



That's covered as well.

  Andy



Thank you very much.

At.te,

Marcelo de Oliveira Costa Machado


Em sex., 9 de out. de 2020 às 11:11, Andy Seaborne 
escreveu:




On 09/10/2020 13:46, Marcelo Machado wrote:

Yes, that is the problem, ja:rule does not accept some directives. If

the

problem was just prefixes I could resolve that by parsing the entire
content, however, I use some directives like @include to add other owl
rules.

If I use ja:rulesFrom with  everything works fine. But in

that

case, I have to save the file in my server and I would not like to do

that.

If not ja:rule I don't know what to do so, I didn't find any doc about

that

(actually seams that what I want is not possible with fuseki).


I've created a ticket
https://issues.apache.org/jira/browse/JENA-1977

and also a tried a quick hack that didn't cause the test suite to
complain so it may be possible to add the header @-directs (and
incidently comments) processing.

How are you getting Fuseki? If it is one of the downloads, could you
test a development build which would speed getting a fix done in time
for the next release.

   Andy




At.te,

Marcelo de Oliveira Costa Machado


Em sex., 9 de out. de 2020 às 08:47, Andy Seaborne 
escreveu:




On 08/10/2020 19:22, Marcelo Machado wrote:

Hello Andy,

I manually escaped \n and " characters and some errors were

corrected,

thanks.  However, consider that I want to use the following string

rules

(

string_rules_variable):


I think (maybe someone can confirm) ja:rule is one or more rules, but
not a full rules file with features of prefixes and other directives.

Does a rule if you use URIs?

Andy



#-*-mode: conf-unix-*-
@prefix time: <http://www.w3.org/2006/time#>
@include 

-> table(owl:sameAs).

#-

sameAs_symmetry:
(?x owl:sameAs ?y)
-> (?y owl:sameAs ?x).

And as I said before this is how I am using in fuseki:

:model_inf a ja:InfModel ;
 ja:baseModel :tdbGraph ;
 ja:reasoner [
 ja:reasonerURL <

http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;

 ja:rule "[string_rules_variable]"`;


But Fuseki is not recognizing prefix:


org.apache.jena.assembler.exceptions.AssemblerException: ca

Re: My own rules in Jena Fuseki

2020-10-11 Thread Marcelo Machado
Thank you Andy, however the error persists.

Let me send you a part of the data I'm trying to upload:

:model_inf a ja:InfModel ;
ja:baseModel :tdbGraph ;
ja:reasoner [
ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
ja:rule "[
#-*-mode: conf-unix-*-
@prefix time: <http://www.w3.org/2006/time#>
@include 

-> table(owl:sameAs).


#---
# Equality

#---

sameAs_symmetry:
(?x owl:sameAs ?y)
-> (?y owl:sameAs ?x) .
]";
]
.

The error:

20:52:05 WARN  Admin   :: [2] RC = 500 : caught: Expected '(' at
start of clause, found @prefix

At '[ #-*-mode: conf-unix-*- @prefix '

org.apache.jena.assembler.exceptions.AssemblerException: caught: Expected
'(' at start of clause, found @prefix

At '[ #-*-mode: conf-unix-*- @prefix '

at
org.apache.jena.assembler.assemblers.AssemblerGroup$PlainAssemblerGroup.openBySpecificType(AssemblerGroup.java:165)
~[fuseki-server.jar:3.17.0-SNAPSHOT]


At.te,

Marcelo de Oliveira Costa Machado


Em dom., 11 de out. de 2020 às 07:52, Andy Seaborne 
escreveu:

>
>
> On 09/10/2020 18:42, Marcelo Machado wrote:
> > I just downloaded the binary distribution of Fuseki2 and used the
> > ./fuseki_server command to start a server. But I will get the development
> > build.
>
> Build ready:
>
>
> https://repository.apache.org/content/groups/snapshots/org/apache/jena/apache-jena-fuseki/3.17.0-SNAPSHOT/
>
> look for the latest
>
> At least dated:
>
> Sun Oct 11
>
> apache-jena-fuseki-3.17.0-20201011
>
>
> >
> > Just pointing out, I believe that the problem is not only with prefix but
> > with any directives other than the rules, for example, @include
> 
>
> That's covered as well.
>
>  Andy
>
> >
> > Thank you very much.
> >
> > At.te,
> >
> > Marcelo de Oliveira Costa Machado
> >
> >
> > Em sex., 9 de out. de 2020 às 11:11, Andy Seaborne 
> > escreveu:
> >
> >>
> >>
> >> On 09/10/2020 13:46, Marcelo Machado wrote:
> >>> Yes, that is the problem, ja:rule does not accept some directives. If
> the
> >>> problem was just prefixes I could resolve that by parsing the entire
> >>> content, however, I use some directives like @include to add other owl
> >>> rules.
> >>>
> >>> If I use ja:rulesFrom with  everything works fine. But in
> >> that
> >>> case, I have to save the file in my server and I would not like to do
> >> that.
> >>> If not ja:rule I don't know what to do so, I didn't find any doc about
> >> that
> >>> (actually seams that what I want is not possible with fuseki).
> >>
> >> I've created a ticket
> >> https://issues.apache.org/jira/browse/JENA-1977
> >>
> >> and also a tried a quick hack that didn't cause the test suite to
> >> complain so it may be possible to add the header @-directs (and
> >> incidently comments) processing.
> >>
> >> How are you getting Fuseki? If it is one of the downloads, could you
> >> test a development build which would speed getting a fix done in time
> >> for the next release.
> >>
> >>   Andy
> >>
> >>>
> >>>
> >>> At.te,
> >>>
> >>> Marcelo de Oliveira Costa Machado
> >>>
> >>>
> >>> Em sex., 9 de out. de 2020 às 08:47, Andy Seaborne 
> >>> escreveu:
> >>>
> >>>>
> >>>>
> >>>> On 08/10/2020 19:22, Marcelo Machado wrote:
> >>>>> Hello Andy,
> >>>>>
> >>>>> I manually escaped \n and " characters and some errors were
> corrected,
> >>>>> thanks.  However, consider that I want to use the following string
> >> rules
> >>>> (
> >>>>> string_rules_variable):
> >>>>
> >>>> I think (maybe someone can confirm) ja:rule is one or more rules, but
> >>>> not a full rules file with features of prefixes and other directives.
> >>>>
> >>>> Does a rule if you use URIs?
> >>>>
> >>>>Andy
> >>>>
> >>>>>
> >>>>> #-*-mode: conf-unix-*-
> >>>>> @prefix time: <http://www.w3.org/2006/time#>
> >>&

Re: My own rules in Jena Fuseki

2020-10-11 Thread Andy Seaborne




On 09/10/2020 18:42, Marcelo Machado wrote:

I just downloaded the binary distribution of Fuseki2 and used the
./fuseki_server command to start a server. But I will get the development
build.


Build ready:

https://repository.apache.org/content/groups/snapshots/org/apache/jena/apache-jena-fuseki/3.17.0-SNAPSHOT/

look for the latest

At least dated:

Sun Oct 11

apache-jena-fuseki-3.17.0-20201011




Just pointing out, I believe that the problem is not only with prefix but
with any directives other than the rules, for example, @include 


That's covered as well.

Andy



Thank you very much.

At.te,

Marcelo de Oliveira Costa Machado


Em sex., 9 de out. de 2020 às 11:11, Andy Seaborne 
escreveu:




On 09/10/2020 13:46, Marcelo Machado wrote:

Yes, that is the problem, ja:rule does not accept some directives. If the
problem was just prefixes I could resolve that by parsing the entire
content, however, I use some directives like @include to add other owl
rules.

If I use ja:rulesFrom with  everything works fine. But in

that

case, I have to save the file in my server and I would not like to do

that.

If not ja:rule I don't know what to do so, I didn't find any doc about

that

(actually seams that what I want is not possible with fuseki).


I've created a ticket
https://issues.apache.org/jira/browse/JENA-1977

and also a tried a quick hack that didn't cause the test suite to
complain so it may be possible to add the header @-directs (and
incidently comments) processing.

How are you getting Fuseki? If it is one of the downloads, could you
test a development build which would speed getting a fix done in time
for the next release.

  Andy




At.te,

Marcelo de Oliveira Costa Machado


Em sex., 9 de out. de 2020 às 08:47, Andy Seaborne 
escreveu:




On 08/10/2020 19:22, Marcelo Machado wrote:

Hello Andy,

I manually escaped \n and " characters and some errors were corrected,
thanks.  However, consider that I want to use the following string

rules

(

string_rules_variable):


I think (maybe someone can confirm) ja:rule is one or more rules, but
not a full rules file with features of prefixes and other directives.

Does a rule if you use URIs?

   Andy



#-*-mode: conf-unix-*-
@prefix time: <http://www.w3.org/2006/time#>
@include 

-> table(owl:sameAs).

#-

sameAs_symmetry:
(?x owl:sameAs ?y)
-> (?y owl:sameAs ?x).

And as I said before this is how I am using in fuseki:

:model_inf a ja:InfModel ;
ja:baseModel :tdbGraph ;
ja:reasoner [
ja:reasonerURL <

http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;

ja:rule "[string_rules_variable]"`;


But Fuseki is not recognizing prefix:


org.apache.jena.assembler.exceptions.AssemblerException: caught:
Expected '(' at start of clause, found @prefix



Do you have any thoughts on how to solve this?

Thanks in advance!






At.te,

Marcelo de Oliveira Costa Machado


Em qui., 8 de out. de 2020 às 05:47, Andy Seaborne 
escreveu:




On 08/10/2020 07:41, Marcelo Machado wrote:

I am trying to create my own property rules in fuseki. To do so I am

using

the Generic Rule Reasoning that allows me to use my own rules. When I

use

this strategy with my rules in a file everything works fine:

:model_inf a ja:InfModel ;
ja:baseModel :tdbGraph ;
ja:reasoner [
ja:reasonerURL <

http://jena.hpl.hp.com/2003/GenericRuleReasoner>

;

ja:rulesFrom  ;
] .

However, I would not want to use a file but add the rules directly

as a

string. I tried just to copy the content of the rule files that

worked

in

the example above, but the repository was not created, apparently due

to

special characters (e.g. #, \n...):

:model_inf a ja:InfModel ;
ja:baseModel :tdbGraph ;
ja:reasoner [
ja:reasonerURL <

http://jena.hpl.hp.com/2003/GenericRuleReasoner>

;

ja:rule "[${string_rules_variable}]"`;


At a minimum that will need Turtle escapes for newlines. A

NodeFormatter

 formst outout - the Turtle rules are available directly via
EscapeStr.stringEsc(string).

The full grammar details are here:

https://www.w3.org/TR/turtle/#terminals


If you need to be it your self, it'll need newline  and " handling,

two

character \n and \"

    Andy


] .
where ${string_rules_variable} (javascript string interpolation)

contains

the rules read from the file.

So, what am I doing wrong? I believe this is about escaping special
characters, if so, what would be the way to resolve it?

At.te,

Marcelo de Oliveira Costa Machado















Re: My own rules in Jena Fuseki

2020-10-09 Thread Marcelo Machado
I just downloaded the binary distribution of Fuseki2 and used the
./fuseki_server command to start a server. But I will get the development
build.

Just pointing out, I believe that the problem is not only with prefix but
with any directives other than the rules, for example, @include 

Thank you very much.

At.te,

Marcelo de Oliveira Costa Machado


Em sex., 9 de out. de 2020 às 11:11, Andy Seaborne 
escreveu:

>
>
> On 09/10/2020 13:46, Marcelo Machado wrote:
> > Yes, that is the problem, ja:rule does not accept some directives. If the
> > problem was just prefixes I could resolve that by parsing the entire
> > content, however, I use some directives like @include to add other owl
> > rules.
> >
> > If I use ja:rulesFrom with  everything works fine. But in
> that
> > case, I have to save the file in my server and I would not like to do
> that.
> > If not ja:rule I don't know what to do so, I didn't find any doc about
> that
> > (actually seams that what I want is not possible with fuseki).
>
> I've created a ticket
> https://issues.apache.org/jira/browse/JENA-1977
>
> and also a tried a quick hack that didn't cause the test suite to
> complain so it may be possible to add the header @-directs (and
> incidently comments) processing.
>
> How are you getting Fuseki? If it is one of the downloads, could you
> test a development build which would speed getting a fix done in time
> for the next release.
>
>  Andy
>
> >
> >
> > At.te,
> >
> > Marcelo de Oliveira Costa Machado
> >
> >
> > Em sex., 9 de out. de 2020 às 08:47, Andy Seaborne 
> > escreveu:
> >
> >>
> >>
> >> On 08/10/2020 19:22, Marcelo Machado wrote:
> >>> Hello Andy,
> >>>
> >>> I manually escaped \n and " characters and some errors were corrected,
> >>> thanks.  However, consider that I want to use the following string
> rules
> >> (
> >>> string_rules_variable):
> >>
> >> I think (maybe someone can confirm) ja:rule is one or more rules, but
> >> not a full rules file with features of prefixes and other directives.
> >>
> >> Does a rule if you use URIs?
> >>
> >>   Andy
> >>
> >>>
> >>> #-*-mode: conf-unix-*-
> >>> @prefix time: <http://www.w3.org/2006/time#>
> >>> @include 
> >>>
> >>> -> table(owl:sameAs).
> >>>
> >>> #-
> >>>
> >>> sameAs_symmetry:
> >>> (?x owl:sameAs ?y)
> >>> -> (?y owl:sameAs ?x).
> >>>
> >>> And as I said before this is how I am using in fuseki:
> >>>> :model_inf a ja:InfModel ;
> >>>>ja:baseModel :tdbGraph ;
> >>>>ja:reasoner [
> >>>>ja:reasonerURL <
> >> http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
> >>>>ja:rule "[string_rules_variable]"`;
> >>>
> >>> But Fuseki is not recognizing prefix:
> >>>
> >>>
> >>> org.apache.jena.assembler.exceptions.AssemblerException: caught:
> >>> Expected '(' at start of clause, found @prefix
> >>>
> >>>
> >>>
> >>> Do you have any thoughts on how to solve this?
> >>>
> >>> Thanks in advance!
> >>>
> >>>
> >>>
> >>>
> >>>
> >>>
> >>> At.te,
> >>>
> >>> Marcelo de Oliveira Costa Machado
> >>>
> >>>
> >>> Em qui., 8 de out. de 2020 às 05:47, Andy Seaborne 
> >>> escreveu:
> >>>
> >>>>
> >>>>
> >>>> On 08/10/2020 07:41, Marcelo Machado wrote:
> >>>>> I am trying to create my own property rules in fuseki. To do so I am
> >>>> using
> >>>>> the Generic Rule Reasoning that allows me to use my own rules. When I
> >> use
> >>>>> this strategy with my rules in a file everything works fine:
> >>>>>
> >>>>> :model_inf a ja:InfModel ;
> >>>>>ja:baseModel :tdbGraph ;
> >>>>>ja:reasoner [
> >>>>>ja:reasonerURL <
> >> http://jena.hpl.hp.com/2003/GenericRuleReasoner>
> >>>> ;
> >>>>>ja:rulesFrom  ;
> >>>>>] .
> >>>>>
> >&g

Re: My own rules in Jena Fuseki

2020-10-09 Thread Andy Seaborne




On 09/10/2020 13:46, Marcelo Machado wrote:

Yes, that is the problem, ja:rule does not accept some directives. If the
problem was just prefixes I could resolve that by parsing the entire
content, however, I use some directives like @include to add other owl
rules.

If I use ja:rulesFrom with  everything works fine. But in that
case, I have to save the file in my server and I would not like to do that.
If not ja:rule I don't know what to do so, I didn't find any doc about that
(actually seams that what I want is not possible with fuseki).


I've created a ticket
https://issues.apache.org/jira/browse/JENA-1977

and also a tried a quick hack that didn't cause the test suite to 
complain so it may be possible to add the header @-directs (and 
incidently comments) processing.


How are you getting Fuseki? If it is one of the downloads, could you 
test a development build which would speed getting a fix done in time 
for the next release.


Andy




At.te,

Marcelo de Oliveira Costa Machado


Em sex., 9 de out. de 2020 às 08:47, Andy Seaborne 
escreveu:




On 08/10/2020 19:22, Marcelo Machado wrote:

Hello Andy,

I manually escaped \n and " characters and some errors were corrected,
thanks.  However, consider that I want to use the following string rules

(

string_rules_variable):


I think (maybe someone can confirm) ja:rule is one or more rules, but
not a full rules file with features of prefixes and other directives.

Does a rule if you use URIs?

  Andy



#-*-mode: conf-unix-*-
@prefix time: <http://www.w3.org/2006/time#>
@include 

-> table(owl:sameAs).

#-

sameAs_symmetry:
(?x owl:sameAs ?y)
-> (?y owl:sameAs ?x).

And as I said before this is how I am using in fuseki:

:model_inf a ja:InfModel ;
   ja:baseModel :tdbGraph ;
   ja:reasoner [
   ja:reasonerURL <

http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;

   ja:rule "[string_rules_variable]"`;


But Fuseki is not recognizing prefix:


org.apache.jena.assembler.exceptions.AssemblerException: caught:
Expected '(' at start of clause, found @prefix



Do you have any thoughts on how to solve this?

Thanks in advance!






At.te,

Marcelo de Oliveira Costa Machado


Em qui., 8 de out. de 2020 às 05:47, Andy Seaborne 
escreveu:




On 08/10/2020 07:41, Marcelo Machado wrote:

I am trying to create my own property rules in fuseki. To do so I am

using

the Generic Rule Reasoning that allows me to use my own rules. When I

use

this strategy with my rules in a file everything works fine:

:model_inf a ja:InfModel ;
   ja:baseModel :tdbGraph ;
   ja:reasoner [
   ja:reasonerURL <

http://jena.hpl.hp.com/2003/GenericRuleReasoner>

;

   ja:rulesFrom  ;
   ] .

However, I would not want to use a file but add the rules directly as a
string. I tried just to copy the content of the rule files that worked

in

the example above, but the repository was not created, apparently due

to

special characters (e.g. #, \n...):

:model_inf a ja:InfModel ;
   ja:baseModel :tdbGraph ;
   ja:reasoner [
   ja:reasonerURL <

http://jena.hpl.hp.com/2003/GenericRuleReasoner>

;

   ja:rule "[${string_rules_variable}]"`;


At a minimum that will need Turtle escapes for newlines. A NodeFormatter
formst outout - the Turtle rules are available directly via
EscapeStr.stringEsc(string).

The full grammar details are here:

https://www.w3.org/TR/turtle/#terminals


If you need to be it your self, it'll need newline  and " handling, two
character \n and \"

   Andy


   ] .
where ${string_rules_variable} (javascript string interpolation)

contains

the rules read from the file.

So, what am I doing wrong? I believe this is about escaping special
characters, if so, what would be the way to resolve it?

At.te,

Marcelo de Oliveira Costa Machado











Re: My own rules in Jena Fuseki

2020-10-09 Thread Marcelo Machado
Yes, that is the problem, ja:rule does not accept some directives. If the
problem was just prefixes I could resolve that by parsing the entire
content, however, I use some directives like @include to add other owl
rules.

If I use ja:rulesFrom with  everything works fine. But in that
case, I have to save the file in my server and I would not like to do that.
If not ja:rule I don't know what to do so, I didn't find any doc about that
(actually seams that what I want is not possible with fuseki).


At.te,

Marcelo de Oliveira Costa Machado


Em sex., 9 de out. de 2020 às 08:47, Andy Seaborne 
escreveu:

>
>
> On 08/10/2020 19:22, Marcelo Machado wrote:
> > Hello Andy,
> >
> > I manually escaped \n and " characters and some errors were corrected,
> > thanks.  However, consider that I want to use the following string rules
> (
> > string_rules_variable):
>
> I think (maybe someone can confirm) ja:rule is one or more rules, but
> not a full rules file with features of prefixes and other directives.
>
> Does a rule if you use URIs?
>
>  Andy
>
> >
> > #-*-mode: conf-unix-*-
> > @prefix time: <http://www.w3.org/2006/time#>
> > @include 
> >
> > -> table(owl:sameAs).
> >
> > #-
> >
> > sameAs_symmetry:
> > (?x owl:sameAs ?y)
> > -> (?y owl:sameAs ?x).
> >
> > And as I said before this is how I am using in fuseki:
> >> :model_inf a ja:InfModel ;
> >>   ja:baseModel :tdbGraph ;
> >>   ja:reasoner [
> >>   ja:reasonerURL <
> http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
> >>   ja:rule "[string_rules_variable]"`;
> >
> > But Fuseki is not recognizing prefix:
> >
> >
> > org.apache.jena.assembler.exceptions.AssemblerException: caught:
> > Expected '(' at start of clause, found @prefix
> >
> >
> >
> > Do you have any thoughts on how to solve this?
> >
> > Thanks in advance!
> >
> >
> >
> >
> >
> >
> > At.te,
> >
> > Marcelo de Oliveira Costa Machado
> >
> >
> > Em qui., 8 de out. de 2020 às 05:47, Andy Seaborne 
> > escreveu:
> >
> >>
> >>
> >> On 08/10/2020 07:41, Marcelo Machado wrote:
> >>> I am trying to create my own property rules in fuseki. To do so I am
> >> using
> >>> the Generic Rule Reasoning that allows me to use my own rules. When I
> use
> >>> this strategy with my rules in a file everything works fine:
> >>>
> >>> :model_inf a ja:InfModel ;
> >>>   ja:baseModel :tdbGraph ;
> >>>   ja:reasoner [
> >>>   ja:reasonerURL <
> http://jena.hpl.hp.com/2003/GenericRuleReasoner>
> >> ;
> >>>   ja:rulesFrom  ;
> >>>   ] .
> >>>
> >>> However, I would not want to use a file but add the rules directly as a
> >>> string. I tried just to copy the content of the rule files that worked
> in
> >>> the example above, but the repository was not created, apparently due
> to
> >>> special characters (e.g. #, \n...):
> >>>
> >>> :model_inf a ja:InfModel ;
> >>>   ja:baseModel :tdbGraph ;
> >>>   ja:reasoner [
> >>>   ja:reasonerURL <
> http://jena.hpl.hp.com/2003/GenericRuleReasoner>
> >> ;
> >>>   ja:rule "[${string_rules_variable}]"`;
> >>
> >> At a minimum that will need Turtle escapes for newlines. A NodeFormatter
> >>formst outout - the Turtle rules are available directly via
> >> EscapeStr.stringEsc(string).
> >>
> >> The full grammar details are here:
> https://www.w3.org/TR/turtle/#terminals
> >>
> >> If you need to be it your self, it'll need newline  and " handling, two
> >> character \n and \"
> >>
> >>   Andy
> >>
> >>>   ] .
> >>> where ${string_rules_variable} (javascript string interpolation)
> contains
> >>> the rules read from the file.
> >>>
> >>> So, what am I doing wrong? I believe this is about escaping special
> >>> characters, if so, what would be the way to resolve it?
> >>>
> >>> At.te,
> >>>
> >>> Marcelo de Oliveira Costa Machado
> >>>
> >>
> >
>


Re: My own rules in Jena Fuseki

2020-10-09 Thread Andy Seaborne




On 08/10/2020 19:22, Marcelo Machado wrote:

Hello Andy,

I manually escaped \n and " characters and some errors were corrected,
thanks.  However, consider that I want to use the following string rules (
string_rules_variable):


I think (maybe someone can confirm) ja:rule is one or more rules, but 
not a full rules file with features of prefixes and other directives.


Does a rule if you use URIs?

Andy



#-*-mode: conf-unix-*-
@prefix time: <http://www.w3.org/2006/time#>
@include 

-> table(owl:sameAs).

#-

sameAs_symmetry:
(?x owl:sameAs ?y)
-> (?y owl:sameAs ?x).

And as I said before this is how I am using in fuseki:

:model_inf a ja:InfModel ;
  ja:baseModel :tdbGraph ;
  ja:reasoner [
  ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
  ja:rule "[string_rules_variable]"`;


But Fuseki is not recognizing prefix:


org.apache.jena.assembler.exceptions.AssemblerException: caught:
Expected '(' at start of clause, found @prefix



Do you have any thoughts on how to solve this?

Thanks in advance!






At.te,

Marcelo de Oliveira Costa Machado


Em qui., 8 de out. de 2020 às 05:47, Andy Seaborne 
escreveu:




On 08/10/2020 07:41, Marcelo Machado wrote:

I am trying to create my own property rules in fuseki. To do so I am

using

the Generic Rule Reasoning that allows me to use my own rules. When I use
this strategy with my rules in a file everything works fine:

:model_inf a ja:InfModel ;
  ja:baseModel :tdbGraph ;
  ja:reasoner [
  ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner>

;

  ja:rulesFrom  ;
  ] .

However, I would not want to use a file but add the rules directly as a
string. I tried just to copy the content of the rule files that worked in
the example above, but the repository was not created, apparently due to
special characters (e.g. #, \n...):

:model_inf a ja:InfModel ;
  ja:baseModel :tdbGraph ;
  ja:reasoner [
  ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner>

;

  ja:rule "[${string_rules_variable}]"`;


At a minimum that will need Turtle escapes for newlines. A NodeFormatter
   formst outout - the Turtle rules are available directly via
EscapeStr.stringEsc(string).

The full grammar details are here: https://www.w3.org/TR/turtle/#terminals

If you need to be it your self, it'll need newline  and " handling, two
character \n and \"

  Andy


  ] .
where ${string_rules_variable} (javascript string interpolation) contains
the rules read from the file.

So, what am I doing wrong? I believe this is about escaping special
characters, if so, what would be the way to resolve it?

At.te,

Marcelo de Oliveira Costa Machado







Re: My own rules in Jena Fuseki

2020-10-08 Thread Marcelo Machado
Hello Andy,

I manually escaped \n and " characters and some errors were corrected,
thanks.  However, consider that I want to use the following string rules (
string_rules_variable):

#-*-mode: conf-unix-*-
@prefix time: <http://www.w3.org/2006/time#>
@include 

-> table(owl:sameAs).

#-

sameAs_symmetry:
(?x owl:sameAs ?y)
-> (?y owl:sameAs ?x).

And as I said before this is how I am using in fuseki:
> :model_inf a ja:InfModel ;
>  ja:baseModel :tdbGraph ;
>  ja:reasoner [
>  ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
>  ja:rule "[string_rules_variable]"`;

But Fuseki is not recognizing prefix:


org.apache.jena.assembler.exceptions.AssemblerException: caught:
Expected '(' at start of clause, found @prefix



Do you have any thoughts on how to solve this?

Thanks in advance!






At.te,

Marcelo de Oliveira Costa Machado


Em qui., 8 de out. de 2020 às 05:47, Andy Seaborne 
escreveu:

>
>
> On 08/10/2020 07:41, Marcelo Machado wrote:
> > I am trying to create my own property rules in fuseki. To do so I am
> using
> > the Generic Rule Reasoning that allows me to use my own rules. When I use
> > this strategy with my rules in a file everything works fine:
> >
> > :model_inf a ja:InfModel ;
> >  ja:baseModel :tdbGraph ;
> >  ja:reasoner [
> >  ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner>
> ;
> >  ja:rulesFrom  ;
> >  ] .
> >
> > However, I would not want to use a file but add the rules directly as a
> > string. I tried just to copy the content of the rule files that worked in
> > the example above, but the repository was not created, apparently due to
> > special characters (e.g. #, \n...):
> >
> > :model_inf a ja:InfModel ;
> >  ja:baseModel :tdbGraph ;
> >  ja:reasoner [
> >  ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner>
> ;
> >  ja:rule "[${string_rules_variable}]"`;
>
> At a minimum that will need Turtle escapes for newlines. A NodeFormatter
>   formst outout - the Turtle rules are available directly via
> EscapeStr.stringEsc(string).
>
> The full grammar details are here: https://www.w3.org/TR/turtle/#terminals
>
> If you need to be it your self, it'll need newline  and " handling, two
> character \n and \"
>
>  Andy
>
> >  ] .
> > where ${string_rules_variable} (javascript string interpolation) contains
> > the rules read from the file.
> >
> > So, what am I doing wrong? I believe this is about escaping special
> > characters, if so, what would be the way to resolve it?
> >
> > At.te,
> >
> > Marcelo de Oliveira Costa Machado
> >
>


Re: My own rules in Jena Fuseki

2020-10-08 Thread Andy Seaborne




On 08/10/2020 07:41, Marcelo Machado wrote:

I am trying to create my own property rules in fuseki. To do so I am using
the Generic Rule Reasoning that allows me to use my own rules. When I use
this strategy with my rules in a file everything works fine:

:model_inf a ja:InfModel ;
 ja:baseModel :tdbGraph ;
 ja:reasoner [
 ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
 ja:rulesFrom  ;
 ] .

However, I would not want to use a file but add the rules directly as a
string. I tried just to copy the content of the rule files that worked in
the example above, but the repository was not created, apparently due to
special characters (e.g. #, \n...):

:model_inf a ja:InfModel ;
 ja:baseModel :tdbGraph ;
 ja:reasoner [
 ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
 ja:rule "[${string_rules_variable}]"`;


At a minimum that will need Turtle escapes for newlines. A NodeFormatter 
 formst outout - the Turtle rules are available directly via 
EscapeStr.stringEsc(string).


The full grammar details are here: https://www.w3.org/TR/turtle/#terminals

If you need to be it your self, it'll need newline  and " handling, two 
character \n and \"


Andy


 ] .
where ${string_rules_variable} (javascript string interpolation) contains
the rules read from the file.

So, what am I doing wrong? I believe this is about escaping special
characters, if so, what would be the way to resolve it?

At.te,

Marcelo de Oliveira Costa Machado



My own rules in Jena Fuseki

2020-10-07 Thread Marcelo Machado
I am trying to create my own property rules in fuseki. To do so I am using
the Generic Rule Reasoning that allows me to use my own rules. When I use
this strategy with my rules in a file everything works fine:

:model_inf a ja:InfModel ;
ja:baseModel :tdbGraph ;
ja:reasoner [
ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
ja:rulesFrom  ;
] .

However, I would not want to use a file but add the rules directly as a
string. I tried just to copy the content of the rule files that worked in
the example above, but the repository was not created, apparently due to
special characters (e.g. #, \n...):

:model_inf a ja:InfModel ;
ja:baseModel :tdbGraph ;
ja:reasoner [
ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
ja:rule "[${string_rules_variable}]"`;
] .
where ${string_rules_variable} (javascript string interpolation) contains
the rules read from the file.

So, what am I doing wrong? I believe this is about escaping special
characters, if so, what would be the way to resolve it?

At.te,

Marcelo de Oliveira Costa Machado


RE: Add rules at runtime

2020-10-05 Thread Nouwt, B. (Barry)
Hi Johan, 

I do not think Apache Jena Fuseki supports uploading a rule file as you would 
do with data. Apache Jena rules 
(https://jena.apache.org/documentation/inference/) can only be set as part of 
the configuration of a dataset, I think.

However, if you use another type of constraints/rules (i.e. SWRL or OWL 
Restrictions), you can maybe upload those as part of your data (as they are 
part of you ontology, I think). If you then use a reasoner that supports those 
constraints/rules (Pellet maybe?), it will probably take them into account.

Hope this helps!

Regards, Barry

-Original Message-
From: Johan Kumps  
Sent: maandag 5 oktober 2020 13:37
To: users@jena.apache.org
Subject: Add rules at runtime

Hi all,

Is it possible to add rules to Jena at runtime or is it only possible to add 
rules via a file and restart the server?

It would be very nice if you could upload a rule the same way as you can do to 
add data to a dataset.

Kind regards,
Johan,
This message may contain information that is not intended for you. If you are 
not the addressee or if this message was sent to you by mistake, you are 
requested to inform the sender and delete the message. TNO accepts no liability 
for the content of this e-mail, for the manner in which you use it and for 
damage of any kind resulting from the risks inherent to the electronic 
transmission of messages.


Add rules at runtime

2020-10-05 Thread Johan Kumps
Hi all,

Is it possible to add rules to Jena at runtime or is it only possible to
add rules via a file and restart the server?

It would be very nice if you could upload a rule the same way as you can do
to add data to a dataset.

Kind regards,
Johan,


RE: load rules file via class loader (as a resource)

2020-07-30 Thread Nouwt, B. (Barry)
Hi Andy, thanks for looking into it. After further investigation; the 
C:some.rules only occurs when using an absolute path with windows separators 
(see below).I've now updated all our code to indeed use linux separators to get 
consistent behavior and this solved theses problems for me. Thanks you very 
much.

Regarding the C:some.rules issue; I've updated the github code and it gives the 
following outcomes for each commented/uncommented option on lines 9-12 
(probably requires windows):

- absolute windows path (line 9): 
builder.parseConfigFile("C:\\Users\\nouwtb\\git\\jena-example\\src\\test\\resources\\config.ttl");
- fails, with org.apache.jena.shared.RulesetNotFoundException: 
C:some.rules

- relative windows path (line 10): 
builder.parseConfigFile("src\\test\\resources\\config.ttl");
- fails, with org.apache.jena.shared.RulesetNotFoundException: 
file:///C:/Users/nouwtb/git/jena-example/some.rules

- absolute linux path (line 11): 
builder.parseConfigFile("C:/Users/nouwtb/git/jena-example/src/test/resources/config.ttl");
- succeeds, path at RuleSetAssembler.addExternalRules is: 
C:/Users/nouwtb/git/jena-example/src/test/resources/some.rules

- relative linux path (line 12): 
builder.parseConfigFile("src/test/resources/config.ttl");
- succeeds, path at RuleSetAssembler.addExternalRules is: 
file:///C:/Users/nouwtb/git/jena-example/src/test/resources/some.rules

Regards, Barry

-Original Message-
From: Andy Seaborne  
Sent: donderdag 30 juli 2020 10:56
To: users@jena.apache.org
Subject: Re: load rules file via class loader (as a resource)



On 07/07/2020 12:56, Nouwt, B. (Barry) wrote:
> Hey Andy, thanks for helping out!
> 
> I've tried to setup a stripped down version of the behavior here: 
> https://github.com/barrynl/jena-example
> 
> The idea was to run *JenaPathTest.java* from your IDE (in my case Eclipse) 
> and demonstrate the inconsistent behavior, but I cannot reproduce the 
> behavior I was describing below.
> 
> One of the differences I notice in this example using the debugger (if I set 
> a breakpoint in 
> org.apache.jena.assembler.assemblers.RuleSetAssembler.addExternalRules(Resource,
>  List)) is that the object resource of the ja:rulesFrom triple is an 
> absolute full path string 
> (file:///C:/Users/.../jena-example/src/test/resources/some.rules) to the 
> some.rules file, while in our actual application it stays a relative url 
> (C:some.rules).

This is the part I can't reproduce nor see in the code where it might become 
"C:some.rules". I'm probably looking in the right place but I'm not seeing it.

"C:some.rules" vs "file:///C:/.../some.rules" is a matter of what the base URI 
is set to though I don't see why there is no "file:".

> I'll check out if I can find differences between these Java applications that 
> might explain it.
> 
> - intercepted this email before actual sending to give additional 
> info where I could reproduce the issue -
> 
> I've probably found the cause of this difference in behavior. Depending on 
> the slashes (forward or backward) you use in the path string you pass to 
> org.apache.jena.fuseki.main.FusekiServer.Builder.parseConfigFile(String), the 
> behavior changes. So:
> 
> - if you use backward slashes (either in an absolute or relative path), it 
> fails because it resolves the some.rules file relative to the working 
> directory root of the jena-example. It does fail differently between absolute 
> and relative.
> - if you use forward slashes (either in an absolute or relative path), it 
> succeeds and loads the some.rules file relative to the config.ttl location.
> 
> This might happen because backward slashes (those that windows uses) trigger 
> some obscure code located in java.io.WinNTFileSystem...in an attempt to 
> normalize the path.

Within Jena, you can always use forward-slash - i.e. URL style, with or without 
URI scheme "file:", "file:///"

Did you find anything else out? because this one is quite strange.

 Andy

> 
> Regards, Barry
> 
> -Original Message-
> From: Andy Seaborne 
> Sent: dinsdag 7 juli 2020 12:08
> To: users@jena.apache.org
> Subject: Re: load rules file via class loader (as a resource)
> 
> Could you provide a stripped down file that illustrates the effect?
> And what does "riot --pretty TTL FILE" show as output.
> 
> One last factor - I presume you use
> FusekiServer.create().parseConfigFile(FILE)
> 
> URIs should be relative to the config file unless it has a BASE.
> 
> On 07/07/2020 07:35, Nouwt, B. (Barry) wrote:
>> Hi Andy, thanks, I'm indeed using Apache Jena Main (i.e. embedded into a 
>> Java application).
&

Re: load rules file via class loader (as a resource)

2020-07-30 Thread Andy Seaborne




On 07/07/2020 12:56, Nouwt, B. (Barry) wrote:

Hey Andy, thanks for helping out!

I've tried to setup a stripped down version of the behavior here: 
https://github.com/barrynl/jena-example

The idea was to run *JenaPathTest.java* from your IDE (in my case Eclipse) and 
demonstrate the inconsistent behavior, but I cannot reproduce the behavior I 
was describing below.

One of the differences I notice in this example using the debugger (if I set a 
breakpoint in 
org.apache.jena.assembler.assemblers.RuleSetAssembler.addExternalRules(Resource, 
List)) is that the object resource of the ja:rulesFrom triple is an 
absolute full path string 
(file:///C:/Users/.../jena-example/src/test/resources/some.rules) to the some.rules 
file, while in our actual application it stays a relative url (C:some.rules).


This is the part I can't reproduce nor see in the code where it might 
become "C:some.rules". I'm probably looking in the right place but I'm 
not seeing it.


"C:some.rules" vs "file:///C:/.../some.rules" is a matter of what the 
base URI is set to though I don't see why there is no "file:".



I'll check out if I can find differences between these Java applications that 
might explain it.

- intercepted this email before actual sending to give additional info 
where I could reproduce the issue -

I've probably found the cause of this difference in behavior. Depending on the 
slashes (forward or backward) you use in the path string you pass to 
org.apache.jena.fuseki.main.FusekiServer.Builder.parseConfigFile(String), the 
behavior changes. So:

- if you use backward slashes (either in an absolute or relative path), it 
fails because it resolves the some.rules file relative to the working directory 
root of the jena-example. It does fail differently between absolute and 
relative.
- if you use forward slashes (either in an absolute or relative path), it 
succeeds and loads the some.rules file relative to the config.ttl location.

This might happen because backward slashes (those that windows uses) trigger 
some obscure code located in java.io.WinNTFileSystem...in an attempt to 
normalize the path.


Within Jena, you can always use forward-slash - i.e. URL style, with or 
without URI scheme "file:", "file:///"


Did you find anything else out? because this one is quite strange.

Andy



Regards, Barry

-Original Message-
From: Andy Seaborne 
Sent: dinsdag 7 juli 2020 12:08
To: users@jena.apache.org
Subject: Re: load rules file via class loader (as a resource)

Could you provide a stripped down file that illustrates the effect?
And what does "riot --pretty TTL FILE" show as output.

One last factor - I presume you use
FusekiServer.create().parseConfigFile(FILE)

URIs should be relative to the config file unless it has a BASE.

On 07/07/2020 07:35, Nouwt, B. (Barry) wrote:

Hi Andy, thanks, I'm indeed using Apache Jena Main (i.e. embedded into a Java 
application).

One of our developers uses a Mac with Eclipse and the problem we are 
experiencing is that we cannot find a value for the ja:rulesFrom that works 
both from Windows Eclipse and on Mac Eclipse (that's why I want to try 
classpath, because it might be more consistent between OSs).

On Windows it resolves the relative path relative to the working directory of the JVM (so 
it needs a value like ), while on Mac it seems to 
resolve it relative to the location of the config.ttl file (so it needs a value like 
.


If debugging trace is on, it should show the full URI.

If it is relative after reading the config file, then there wasn't a base at 
parse time which I can't understand.



I am not sure what causes this difference, but one of the things I noticed is that 
the resource gets translated to  while I think on a Mac it will 
not.


C:foo is relative as a file name, to the current directory on the C:
drive.  Jena treats one character URI schemes as Windows drives (hopefully! I 
don't have Windows)

If the attempt to read is  then again it suggests no base URI.



Thanks for the pointers to a custom "cp:" LocationMapper...I'll check it out, 
although I do consider this divergence between the Windows and Mac platform undesirable. 
Not sure if it's the JVM or Apache Jena code that causes this...though.

Kind regards, Barry

-Original Message-
From: Andy Seaborne 
Sent: maandag 6 juli 2020 17:08
To: users@jena.apache.org
Subject: Re: load rules file via class loader (as a resource)

Hi Barry,

Plain  is a relative URI so it is going to be resolved in parsing 
the assembler to file:///.../some.rules before it even looks for the rules.

Finding files will include the classpath but it would need a trick to get round 
the resolution.

 will ve left alone and the resource looked for should 
"cp:some.rules"

I can't remember which packing of Fuseki you use.

If its the 

Re: load rules file via class loader (as a resource)

2020-07-09 Thread Andy Seaborne

Barry - thanks.  I'll take a look at that when I can.

About \, could be. Internally, Jena has a bias towards "/" because 
that's the URI way.


Due to a lack of Windows machine, I may be back.

Andy

On 07/07/2020 12:56, Nouwt, B. (Barry) wrote:

Hey Andy, thanks for helping out!

I've tried to setup a stripped down version of the behavior here: 
https://github.com/barrynl/jena-example

The idea was to run *JenaPathTest.java* from your IDE (in my case Eclipse) and 
demonstrate the inconsistent behavior, but I cannot reproduce the behavior I 
was describing below.

One of the differences I notice in this example using the debugger (if I set a 
breakpoint in 
org.apache.jena.assembler.assemblers.RuleSetAssembler.addExternalRules(Resource, 
List)) is that the object resource of the ja:rulesFrom triple is an 
absolute full path string 
(file:///C:/Users/.../jena-example/src/test/resources/some.rules) to the some.rules 
file, while in our actual application it stays a relative url (C:some.rules).

I'll check out if I can find differences between these Java applications that 
might explain it.

- intercepted this email before actual sending to give additional info 
where I could reproduce the issue -

I've probably found the cause of this difference in behavior. Depending on the 
slashes (forward or backward) you use in the path string you pass to 
org.apache.jena.fuseki.main.FusekiServer.Builder.parseConfigFile(String), the 
behavior changes. So:

- if you use backward slashes (either in an absolute or relative path), it 
fails because it resolves the some.rules file relative to the working directory 
root of the jena-example. It does fail differently between absolute and 
relative.
- if you use forward slashes (either in an absolute or relative path), it 
succeeds and loads the some.rules file relative to the config.ttl location.

This might happen because backward slashes (those that windows uses) trigger 
some obscure code located in java.io.WinNTFileSystem...in an attempt to 
normalize the path.

Regards, Barry

-Original Message-
From: Andy Seaborne 
Sent: dinsdag 7 juli 2020 12:08
To: users@jena.apache.org
Subject: Re: load rules file via class loader (as a resource)

Could you provide a stripped down file that illustrates the effect?
And what does "riot --pretty TTL FILE" show as output.

One last factor - I presume you use
FusekiServer.create().parseConfigFile(FILE)

URIs should be relative to the config file unless it has a BASE.

On 07/07/2020 07:35, Nouwt, B. (Barry) wrote:

Hi Andy, thanks, I'm indeed using Apache Jena Main (i.e. embedded into a Java 
application).

One of our developers uses a Mac with Eclipse and the problem we are 
experiencing is that we cannot find a value for the ja:rulesFrom that works 
both from Windows Eclipse and on Mac Eclipse (that's why I want to try 
classpath, because it might be more consistent between OSs).

On Windows it resolves the relative path relative to the working directory of the JVM (so 
it needs a value like ), while on Mac it seems to 
resolve it relative to the location of the config.ttl file (so it needs a value like 
.


If debugging trace is on, it should show the full URI.

If it is relative after reading the config file, then there wasn't a base at 
parse time which I can't understand.



I am not sure what causes this difference, but one of the things I noticed is that 
the resource gets translated to  while I think on a Mac it will 
not.


C:foo is relative as a file name, to the current directory on the C:
drive.  Jena treats one character URI schemes as Windows drives (hopefully! I 
don't have Windows)

If the attempt to read is  then again it suggests no base URI.



Thanks for the pointers to a custom "cp:" LocationMapper...I'll check it out, 
although I do consider this divergence between the Windows and Mac platform undesirable. 
Not sure if it's the JVM or Apache Jena code that causes this...though.

Kind regards, Barry

-Original Message-
From: Andy Seaborne 
Sent: maandag 6 juli 2020 17:08
To: users@jena.apache.org
Subject: Re: load rules file via class loader (as a resource)

Hi Barry,

Plain  is a relative URI so it is going to be resolved in parsing 
the assembler to file:///.../some.rules before it even looks for the rules.

Finding files will include the classpath but it would need a trick to get round 
the resolution.

 will ve left alone and the resource looked for should 
"cp:some.rules"

I can't remember which packing of Fuseki you use.

If its the Fuseki main, launched from a java app, you can add a Locator to the global 
StreamManager and control the interpreation of URI so seeing, e.g. 
 look for "some.rules".

It might work with a LocationMapper but if you are taking control of rule file 
mgt, maybe its better to have a custom locator as LocationMapper has only a 
fixed few re

RE: load rules file via class loader (as a resource)

2020-07-07 Thread Nouwt, B. (Barry)
Hey Andy, thanks for helping out!

I've tried to setup a stripped down version of the behavior here: 
https://github.com/barrynl/jena-example

The idea was to run *JenaPathTest.java* from your IDE (in my case Eclipse) and 
demonstrate the inconsistent behavior, but I cannot reproduce the behavior I 
was describing below. 

One of the differences I notice in this example using the debugger (if I set a 
breakpoint in 
org.apache.jena.assembler.assemblers.RuleSetAssembler.addExternalRules(Resource,
 List)) is that the object resource of the ja:rulesFrom triple is an 
absolute full path string 
(file:///C:/Users/.../jena-example/src/test/resources/some.rules) to the 
some.rules file, while in our actual application it stays a relative url 
(C:some.rules).

I'll check out if I can find differences between these Java applications that 
might explain it.

- intercepted this email before actual sending to give additional info 
where I could reproduce the issue -

I've probably found the cause of this difference in behavior. Depending on the 
slashes (forward or backward) you use in the path string you pass to 
org.apache.jena.fuseki.main.FusekiServer.Builder.parseConfigFile(String), the 
behavior changes. So:

- if you use backward slashes (either in an absolute or relative path), it 
fails because it resolves the some.rules file relative to the working directory 
root of the jena-example. It does fail differently between absolute and 
relative.
- if you use forward slashes (either in an absolute or relative path), it 
succeeds and loads the some.rules file relative to the config.ttl location.

This might happen because backward slashes (those that windows uses) trigger 
some obscure code located in java.io.WinNTFileSystem...in an attempt to 
normalize the path.

Regards, Barry

-Original Message-
From: Andy Seaborne  
Sent: dinsdag 7 juli 2020 12:08
To: users@jena.apache.org
Subject: Re: load rules file via class loader (as a resource)

Could you provide a stripped down file that illustrates the effect?
And what does "riot --pretty TTL FILE" show as output.

One last factor - I presume you use
FusekiServer.create().parseConfigFile(FILE)

URIs should be relative to the config file unless it has a BASE.

On 07/07/2020 07:35, Nouwt, B. (Barry) wrote:
> Hi Andy, thanks, I'm indeed using Apache Jena Main (i.e. embedded into a Java 
> application).
> 
> One of our developers uses a Mac with Eclipse and the problem we are 
> experiencing is that we cannot find a value for the ja:rulesFrom that works 
> both from Windows Eclipse and on Mac Eclipse (that's why I want to try 
> classpath, because it might be more consistent between OSs).
> 
> On Windows it resolves the relative path relative to the working directory of 
> the JVM (so it needs a value like ), while on 
> Mac it seems to resolve it relative to the location of the config.ttl file 
> (so it needs a value like .

If debugging trace is on, it should show the full URI.

If it is relative after reading the config file, then there wasn't a base at 
parse time which I can't understand.

> 
> I am not sure what causes this difference, but one of the things I noticed is 
> that the resource gets translated to  while I think on a Mac it 
> will not.

C:foo is relative as a file name, to the current directory on the C: 
drive.  Jena treats one character URI schemes as Windows drives (hopefully! I 
don't have Windows)

If the attempt to read is  then again it suggests no base URI.

> 
> Thanks for the pointers to a custom "cp:" LocationMapper...I'll check it out, 
> although I do consider this divergence between the Windows and Mac platform 
> undesirable. Not sure if it's the JVM or Apache Jena code that causes 
> this...though.
> 
> Kind regards, Barry
> 
> -Original Message-
> From: Andy Seaborne 
> Sent: maandag 6 juli 2020 17:08
> To: users@jena.apache.org
> Subject: Re: load rules file via class loader (as a resource)
> 
> Hi Barry,
> 
> Plain  is a relative URI so it is going to be resolved in parsing 
> the assembler to file:///.../some.rules before it even looks for the rules.
> 
> Finding files will include the classpath but it would need a trick to get 
> round the resolution.
> 
>  will ve left alone and the resource looked for should 
> "cp:some.rules"
> 
> I can't remember which packing of Fuseki you use.
> 
> If its the Fuseki main, launched from a java app, you can add a Locator to 
> the global StreamManager and control the interpreation of URI so seeing, e.g. 
>  look for "some.rules".
> 
> It might work with a LocationMapper but if you are taking control of rule 
> file mgt, maybe its better to have a custom locator as LocationMapper has 
> only a fixed few rename policies.
> On 06/07

Re: load rules file via class loader (as a resource)

2020-07-07 Thread Andy Seaborne

Could you provide a stripped down file that illustrates the effect?
And what does "riot --pretty TTL FILE" show as output.

One last factor - I presume you use 
FusekiServer.create().parseConfigFile(FILE)


URIs should be relative to the config file unless it has a BASE.

On 07/07/2020 07:35, Nouwt, B. (Barry) wrote:

Hi Andy, thanks, I'm indeed using Apache Jena Main (i.e. embedded into a Java 
application).

One of our developers uses a Mac with Eclipse and the problem we are 
experiencing is that we cannot find a value for the ja:rulesFrom that works 
both from Windows Eclipse and on Mac Eclipse (that's why I want to try 
classpath, because it might be more consistent between OSs).

On Windows it resolves the relative path relative to the working directory of the JVM (so 
it needs a value like ), while on Mac it seems to 
resolve it relative to the location of the config.ttl file (so it needs a value like 
.


If debugging trace is on, it should show the full URI.

If it is relative after reading the config file, then there wasn't a 
base at parse time which I can't understand.




I am not sure what causes this difference, but one of the things I noticed is that 
the resource gets translated to  while I think on a Mac it will 
not.


C:foo is relative as a file name, to the current directory on the C: 
drive.  Jena treats one character URI schemes as Windows drives 
(hopefully! I don't have Windows)


If the attempt to read is  then again it suggests no base URI.



Thanks for the pointers to a custom "cp:" LocationMapper...I'll check it out, 
although I do consider this divergence between the Windows and Mac platform undesirable. 
Not sure if it's the JVM or Apache Jena code that causes this...though.

Kind regards, Barry

-Original Message-
From: Andy Seaborne 
Sent: maandag 6 juli 2020 17:08
To: users@jena.apache.org
Subject: Re: load rules file via class loader (as a resource)

Hi Barry,

Plain  is a relative URI so it is going to be resolved in parsing 
the assembler to file:///.../some.rules before it even looks for the rules.

Finding files will include the classpath but it would need a trick to get round 
the resolution.

 will ve left alone and the resource looked for should 
"cp:some.rules"

I can't remember which packing of Fuseki you use.

If its the Fuseki main, launched from a java app, you can add a Locator to the global 
StreamManager and control the interpreation of URI so seeing, e.g. 
 look for "some.rules".

It might work with a LocationMapper but if you are taking control of rule file 
mgt, maybe its better to have a custom locator as LocationMapper has only a 
fixed few rename policies.
On 06/07/2020 13:02, Nouwt, B. (Barry) wrote:

Hi everyone,

I am starting Apache Jena Fuseki with a Turtle configuration file to set up our 
services and dataset. We have a problem with loading the separate some.rules 
file from the classpath (or via the classloader) using the 'ja:rulesFrom' 
predicate of the reasoner.

If we set the 'ja:rulesFrom' predicate to '' (it expects a resource 
not a literal), the configuration fails to load because it cannot find this file. If 
we look a bit deeper (using the Java debugger), we notice that the 'some.rules' gets 
transformed to 'C:some.rules' somewhere internally and it therefore does not look at 
the classpath, but at the local file system. Is there a way to reference the 
'some.rules' file from the class path if the Turle configuration file is in the same 
location of the JAR? Something like: classloader:some.rules...or just '/some.rules' 
as would work with the this.getClass().getResourceAsStream('/some/rules'). I've tried 
several options, but all fail.

I did notice this in the documentation, which might be what explains
the behaviour: "A resource name with no URI scheme is assumed to be a
local file name."
(https://jena.apache.org/documentation/io/rdf-input.html#api)


That's in the RDFDataMgr etc.

"foo" will be looked up as-is, via the Locators of the StreamManger. The global stream a 
manager includes looking in the classpath for "foo" (no URI resolution).

"classpath" counts as "file system".

  Andy



Regards, Barry


This message may contain information that is not intended for you. If you are 
not the addressee or if this message was sent to you by mistake, you are 
requested to inform the sender and delete the message. TNO accepts no liability 
for the content of this e-mail, for the manner in which you use it and for 
damage of any kind resulting from the risks inherent to the electronic 
transmission of messages.



RE: load rules file via class loader (as a resource)

2020-07-06 Thread Nouwt, B. (Barry)
Hi Andy, thanks, I'm indeed using Apache Jena Main (i.e. embedded into a Java 
application).

One of our developers uses a Mac with Eclipse and the problem we are 
experiencing is that we cannot find a value for the ja:rulesFrom that works 
both from Windows Eclipse and on Mac Eclipse (that's why I want to try 
classpath, because it might be more consistent between OSs).

On Windows it resolves the relative path relative to the working directory of 
the JVM (so it needs a value like ), while on 
Mac it seems to resolve it relative to the location of the config.ttl file (so 
it needs a value like .

I am not sure what causes this difference, but one of the things I noticed is 
that the resource gets translated to  while I think on a Mac it 
will not.

Thanks for the pointers to a custom "cp:" LocationMapper...I'll check it out, 
although I do consider this divergence between the Windows and Mac platform 
undesirable. Not sure if it's the JVM or Apache Jena code that causes 
this...though.

Kind regards, Barry

-Original Message-
From: Andy Seaborne  
Sent: maandag 6 juli 2020 17:08
To: users@jena.apache.org
Subject: Re: load rules file via class loader (as a resource)

Hi Barry,

Plain  is a relative URI so it is going to be resolved in parsing 
the assembler to file:///.../some.rules before it even looks for the rules.

Finding files will include the classpath but it would need a trick to get round 
the resolution.

 will ve left alone and the resource looked for should 
"cp:some.rules"

I can't remember which packing of Fuseki you use.

If its the Fuseki main, launched from a java app, you can add a Locator to the 
global StreamManager and control the interpreation of URI so seeing, e.g. 
 look for "some.rules".

It might work with a LocationMapper but if you are taking control of rule file 
mgt, maybe its better to have a custom locator as LocationMapper has only a 
fixed few rename policies.
On 06/07/2020 13:02, Nouwt, B. (Barry) wrote:
> Hi everyone,
> 
> I am starting Apache Jena Fuseki with a Turtle configuration file to set up 
> our services and dataset. We have a problem with loading the separate 
> some.rules file from the classpath (or via the classloader) using the 
> 'ja:rulesFrom' predicate of the reasoner.
> 
> If we set the 'ja:rulesFrom' predicate to '' (it expects a 
> resource not a literal), the configuration fails to load because it cannot 
> find this file. If we look a bit deeper (using the Java debugger), we notice 
> that the 'some.rules' gets transformed to 'C:some.rules' somewhere internally 
> and it therefore does not look at the classpath, but at the local file 
> system. Is there a way to reference the 'some.rules' file from the class path 
> if the Turle configuration file is in the same location of the JAR? Something 
> like: classloader:some.rules...or just '/some.rules' as would work with the 
> this.getClass().getResourceAsStream('/some/rules'). I've tried several 
> options, but all fail.
> 
> I did notice this in the documentation, which might be what explains 
> the behaviour: "A resource name with no URI scheme is assumed to be a 
> local file name." 
> (https://jena.apache.org/documentation/io/rdf-input.html#api)

That's in the RDFDataMgr etc.

"foo" will be looked up as-is, via the Locators of the StreamManger. The global 
stream a manager includes looking in the classpath for "foo" (no URI 
resolution).

"classpath" counts as "file system".

 Andy

> 
> Regards, Barry
> 
> 
> This message may contain information that is not intended for you. If you are 
> not the addressee or if this message was sent to you by mistake, you are 
> requested to inform the sender and delete the message. TNO accepts no 
> liability for the content of this e-mail, for the manner in which you use it 
> and for damage of any kind resulting from the risks inherent to the 
> electronic transmission of messages.
> 


Re: load rules file via class loader (as a resource)

2020-07-06 Thread Andy Seaborne

Hi Barry,

Plain  is a relative URI so it is going to be resolved in 
parsing the assembler to file:///.../some.rules before it even looks for 
the rules.


Finding files will include the classpath but it would need a trick to 
get round the resolution.


 will ve left alone and the resource looked for should 
"cp:some.rules"


I can't remember which packing of Fuseki you use.

If its the Fuseki main, launched from a java app, you can add a Locator 
to the global StreamManager and control the interpreation of URI so 
seeing, e.g.  look for "some.rules".


It might work with a LocationMapper but if you are taking control of 
rule file mgt, maybe its better to have a custom locator as 
LocationMapper has only a fixed few rename policies.

On 06/07/2020 13:02, Nouwt, B. (Barry) wrote:

Hi everyone,

I am starting Apache Jena Fuseki with a Turtle configuration file to set up our 
services and dataset. We have a problem with loading the separate some.rules 
file from the classpath (or via the classloader) using the 'ja:rulesFrom' 
predicate of the reasoner.

If we set the 'ja:rulesFrom' predicate to '' (it expects a resource 
not a literal), the configuration fails to load because it cannot find this file. If 
we look a bit deeper (using the Java debugger), we notice that the 'some.rules' gets 
transformed to 'C:some.rules' somewhere internally and it therefore does not look at 
the classpath, but at the local file system. Is there a way to reference the 
'some.rules' file from the class path if the Turle configuration file is in the same 
location of the JAR? Something like: classloader:some.rules...or just '/some.rules' 
as would work with the this.getClass().getResourceAsStream('/some/rules'). I've tried 
several options, but all fail.

I did notice this in the documentation, which might be what explains the behaviour: 
"A resource name with no URI scheme is assumed to be a local file name." 
(https://jena.apache.org/documentation/io/rdf-input.html#api)


That's in the RDFDataMgr etc.

"foo" will be looked up as-is, via the Locators of the StreamManger. The 
global stream a manager includes looking in the classpath for "foo" (no 
URI resolution).


"classpath" counts as "file system".

Andy



Regards, Barry


This message may contain information that is not intended for you. If you are 
not the addressee or if this message was sent to you by mistake, you are 
requested to inform the sender and delete the message. TNO accepts no liability 
for the content of this e-mail, for the manner in which you use it and for 
damage of any kind resulting from the risks inherent to the electronic 
transmission of messages.



load rules file via class loader (as a resource)

2020-07-06 Thread Nouwt, B. (Barry)
Hi everyone,

I am starting Apache Jena Fuseki with a Turtle configuration file to set up our 
services and dataset. We have a problem with loading the separate some.rules 
file from the classpath (or via the classloader) using the 'ja:rulesFrom' 
predicate of the reasoner.

If we set the 'ja:rulesFrom' predicate to '' (it expects a resource 
not a literal), the configuration fails to load because it cannot find this 
file. If we look a bit deeper (using the Java debugger), we notice that the 
'some.rules' gets transformed to 'C:some.rules' somewhere internally and it 
therefore does not look at the classpath, but at the local file system. Is 
there a way to reference the 'some.rules' file from the class path if the Turle 
configuration file is in the same location of the JAR? Something like: 
classloader:some.rules...or just '/some.rules' as would work with the 
this.getClass().getResourceAsStream('/some/rules'). I've tried several options, 
but all fail.

I did notice this in the documentation, which might be what explains the 
behaviour: "A resource name with no URI scheme is assumed to be a local file 
name." (https://jena.apache.org/documentation/io/rdf-input.html#api)

Regards, Barry


This message may contain information that is not intended for you. If you are 
not the addressee or if this message was sent to you by mistake, you are 
requested to inform the sender and delete the message. TNO accepts no liability 
for the content of this e-mail, for the manner in which you use it and for 
damage of any kind resulting from the risks inherent to the electronic 
transmission of messages.


Re: Help with inference rules

2020-05-27 Thread Kenneth Keefe
Thank you! That was what I needed and I have learned quite a bit.

Here is the rule I ended up using:

@prefix ro: <http://example.com/ont/roster/>.
>
>  [r1: (?x rdf:type ro:RosterEntry), (?x ro:hasSignature ?sig), regex(?sig,
> '(.*) (.*)', ?first, ?last), uriConcat('
> http://example.com/ont/roster/people/', ?first, ?last, ?y) -> (?y
> ro:hasFirstName ?first),  (?y ro:hasLastName ?last),  (?y rdf:type
> ro:Person)]


With that rule, the inferred model contains:

http://example.com/ont/roster/people/BobSmith type Person .
> http://example.com/ont/roster/people/BobSmith hasLastName "Smith" .
> http://example.com/ont/roster/people/BobSmith hasFirstName "Bob" .
> http://example.com/ont/roster/people/SallyJones type Person .
> http://example.com/ont/roster/people/SallyJones hasLastName "Jones" .
> http://example.com/ont/roster/people/SallyJones hasFirstName "Sally" .
> http://example.com/ont/roster/ versionIRI .
> http://example.com/ont/roster/ type Ontology .
> http://example.com/ont/roster/RosterEntry type Class .
> http://example.com/ont/roster/bobEntry hasSignature "Bob Smith" .
> http://example.com/ont/roster/bobEntry type RosterEntry .
> http://example.com/ont/roster/bobEntry type NamedIndividual .
> http://example.com/ont/roster/Person type Class .
> http://example.com/ont/roster/hasLastName range string .
> http://example.com/ont/roster/hasLastName domain Person .
> http://example.com/ont/roster/hasLastName type DatatypeProperty .
> http://example.com/ont/roster/sallyEntry hasSignature "Sally Jones" .
> http://example.com/ont/roster/sallyEntry type RosterEntry .
> http://example.com/ont/roster/sallyEntry type NamedIndividual .
> http://example.com/ont/roster/hasSignature range string .
> http://example.com/ont/roster/hasSignature domain RosterEntry .
> http://example.com/ont/roster/hasSignature type DatatypeProperty .
> http://example.com/ont/roster/hasFirstName range string .
> http://example.com/ont/roster/hasFirstName domain Person .
> http://example.com/ont/roster/hasFirstName type DatatypeProperty .


On Wed, May 27, 2020 at 2:14 AM Dave Reynolds 
wrote:

> On 27/05/2020 04:54, Kenneth Keefe wrote:
> > Thank you! Can you suggest any texts that teach how to effectively write
> > inference rules for Jena?
>
> I don't know of any though no doubt there's the odd blog post example.
>
> > However, I'm not having success changing the node URIs. When I change the
> > rule to this:
> >
> >   [r1: (?x rdf:type ro:RosterEntry), (?x ro:hasSignature ?sig),
> regex(?sig,
> >> '(.*) (.*)', ?first, ?last), makeSkolem(?y, ?x), uriConcat('
> >> http://example.com/ont/roster/people/', ?first, ?last, ?y) -> (?y
> >> ro:hasFirstName ?first),  (?y ro:hasLastName ?last),  (?y rdf:type
> >> ro:Person)]
> >
> >
> > Jena doesn't seem to infer any new nodes.
> Why have both makeSkolem and uriConcat? You either want to create a URI
> resource as your subject or create a bNode. That's trying to make it
> both, which can never happen so the rule never fires.
>
> > I tried separating it into another rule:
> >
> >   [r1: (?x rdf:type ro:RosterEntry), (?x ro:hasSignature ?sig),
> regex(?sig,
> >> '(.*) (.*)', ?first, ?last), makeSkolem(?y, ?x) -> (?y ro:hasFirstName
> >> ?first),  (?y ro:hasLastName ?last),  (?y rdf:type ro:Person)]
> >>   [r2: (?x rdf:type ro:Person), (?x ro:hasFirstName ?first), (?x
> >> ro:hasLastName ?last), uriConcat('http://example.com/ont/roster/people/
> ',
> >> ?first, ?last, ?y) -> print('woot', ?y)]
> >
> >
> > What is strange is that with the second rule, the inference engine prints
> > out:
> >
> > 'woot' <http://example.com/ont/roster/people/BobSmith>
> > 'woot' <http://example.com/ont/roster/people/SallyJones>
> >
> > But, when I listStatements and print out the InfModel,
> >
> > I get the same node URIs:
> >
> > 1PXx9jabIZ6w9mfO0GygJA== type Person .
> >> 1PXx9jabIZ6w9mfO0GygJA== hasLastName "Jones" .
> >> 1PXx9jabIZ6w9mfO0GygJA== hasFirstName "Sally" .
> >> lOqL7Rx2Lwv5OK6BWD/jSA== type Person .
> >> lOqL7Rx2Lwv5OK6BWD/jSA== hasLastName "Smith" .
> >> lOqL7Rx2Lwv5OK6BWD/jSA== hasFirstName "Bob" .
> >
> >
> > So, does uriConcat not set the node's uri permanently?
>
> Ah, I think you might be imaging that uriConcat somehow rewrites the
> node in an RDF graph so it has a name. No. Like all the rule builtins
> all it does is bind a

Re: Help with inference rules

2020-05-27 Thread Dave Reynolds

On 27/05/2020 04:54, Kenneth Keefe wrote:

Thank you! Can you suggest any texts that teach how to effectively write
inference rules for Jena? 


I don't know of any though no doubt there's the odd blog post example.


However, I'm not having success changing the node URIs. When I change the
rule to this:

  [r1: (?x rdf:type ro:RosterEntry), (?x ro:hasSignature ?sig), regex(?sig,

'(.*) (.*)', ?first, ?last), makeSkolem(?y, ?x), uriConcat('
http://example.com/ont/roster/people/', ?first, ?last, ?y) -> (?y
ro:hasFirstName ?first),  (?y ro:hasLastName ?last),  (?y rdf:type
ro:Person)]



Jena doesn't seem to infer any new nodes.
Why have both makeSkolem and uriConcat? You either want to create a URI 
resource as your subject or create a bNode. That's trying to make it 
both, which can never happen so the rule never fires.



I tried separating it into another rule:

  [r1: (?x rdf:type ro:RosterEntry), (?x ro:hasSignature ?sig), regex(?sig,

'(.*) (.*)', ?first, ?last), makeSkolem(?y, ?x) -> (?y ro:hasFirstName
?first),  (?y ro:hasLastName ?last),  (?y rdf:type ro:Person)]
  [r2: (?x rdf:type ro:Person), (?x ro:hasFirstName ?first), (?x
ro:hasLastName ?last), uriConcat('http://example.com/ont/roster/people/',
?first, ?last, ?y) -> print('woot', ?y)]



What is strange is that with the second rule, the inference engine prints
out:

'woot' <http://example.com/ont/roster/people/BobSmith>
'woot' <http://example.com/ont/roster/people/SallyJones>

But, when I listStatements and print out the InfModel,

I get the same node URIs:

1PXx9jabIZ6w9mfO0GygJA== type Person .

1PXx9jabIZ6w9mfO0GygJA== hasLastName "Jones" .
1PXx9jabIZ6w9mfO0GygJA== hasFirstName "Sally" .
lOqL7Rx2Lwv5OK6BWD/jSA== type Person .
lOqL7Rx2Lwv5OK6BWD/jSA== hasLastName "Smith" .
lOqL7Rx2Lwv5OK6BWD/jSA== hasFirstName "Bob" .



So, does uriConcat not set the node's uri permanently?


Ah, I think you might be imaging that uriConcat somehow rewrites the 
node in an RDF graph so it has a name. No. Like all the rule builtins 
all it does is bind a value to a variable or, if the variable already 
has a value, then test it matches.


So just should just need something like (untested):

 [r1: (?x rdf:type ro:RosterEntry),
  (?x ro:hasSignature ?sig),
  regex(?sig, '(.*) (.*)', ?first, ?last),
 uriConcat('http://example.com/ont/roster/people/', ?first, ?last, ?y)
   -> (?y ro:hasFirstName ?first),
  (?y ro:hasLastName ?last),
  (?y rdf:type ro:Person)]

Dave


On Sun, May 24, 2020 at 6:03 AM Dave Reynolds 
wrote:


Sorry, only just noticed this question. Responses below:

On 20/05/2020 10:41, Kenneth Keefe wrote:

Thanks for all the help so far! I've made some good progress on this
example I'm trying to forge. Here are the files for this example:

Ontology: https://cioi.iti.illinois.edu/ont/examples/roster.owl
Rules: https://cioi.iti.illinois.edu/ont/examples/roster.rules

Using this code:

OntModel model =

ModelFactory.*createOntologyModel*(OntModelSpec.*OWL_MEM*);


model.read("file:roster.owl");

List rules = Rule.*rulesFromURL*("file:roster.rules");

Reasoner reasoner = new GenericRuleReasoner(rules);

InfModel inf = ModelFactory.*createInfModel*(reasoner, model);


printAllStatements(inf);

I get this output (I use the LocalName for the predicates and objects for
readability):

b04230c7-55dc-4e08-92d7-26559c0c478f hasLastName "Smith" .
c33de24f-82f1-4aa2-a78e-73201341b274 type Person .
c812ff54-30bf-49e7-8e35-3544dad096b7 hasFirstName "Sally" .
16b7a887-2fb9-4bdb-a529-34ca8b3137e4 hasFirstName "Bob" .
b31eb7d5-a8ad-469e-ae83-366bdf46fd72 hasLastName "Jones" .
8b46f0c7-4eb2-41e2-8789-8967e8f63eec type Person .
http://example.com/ont/roster/ versionIRI .
http://example.com/ont/roster/ type Ontology .
http://example.com/ont/roster/RosterEntry type Class .
http://example.com/ont/roster/bobEntry hasSignature "Bob Smith" .
http://example.com/ont/roster/bobEntry type RosterEntry .
http://example.com/ont/roster/bobEntry type NamedIndividual .
http://example.com/ont/roster/Person type Class .
http://example.com/ont/roster/hasLastName range string .
http://example.com/ont/roster/hasLastName domain Person .
http://example.com/ont/roster/hasLastName type DatatypeProperty .
http://example.com/ont/roster/sallyEntry hasSignature "Sally Jones" .
http://example.com/ont/roster/sallyEntry type RosterEntry .
http://example.com/ont/roster/sallyEntry type NamedIndividual .
http://example.com/ont/roster/hasSignature range string .
http://example.com/ont/roster/hasSignature domain RosterEntry .
http://example.com/ont/roster/hasSignature type DatatypeProperty .
http://example.com/ont/roster/hasFirstName range string .
http://example.com/ont/roster/hasFirstName domain Person .
htt

Re: Help with inference rules

2020-05-26 Thread Kenneth Keefe
Thank you! Can you suggest any texts that teach how to effectively write
inference rules for Jena? Also, I have made good progress on the Roster
example, but I'm stuck on the new node URI:

I'm successfully creating a new bNode from my rule now, but I'm having
trouble defining the node's URI.

When I use this rule:

 [r1: (?x rdf:type ro:RosterEntry), (?x ro:hasSignature ?sig), regex(?sig,
> '(.*) (.*)', ?first, ?last), makeSkolem(?y, ?x) -> (?y ro:hasFirstName
> ?first),  (?y ro:hasLastName ?last),  (?y rdf:type ro:Person)]


Jena infers two new nodes like I was hoping for:

1PXx9jabIZ6w9mfO0GygJA== type Person .
> 1PXx9jabIZ6w9mfO0GygJA== hasLastName "Jones" .
> 1PXx9jabIZ6w9mfO0GygJA== hasFirstName "Sally" .
> lOqL7Rx2Lwv5OK6BWD/jSA== type Person .
> lOqL7Rx2Lwv5OK6BWD/jSA== hasLastName "Smith" .
> lOqL7Rx2Lwv5OK6BWD/jSA== hasFirstName "Bob" .


However, I'm not having success changing the node URIs. When I change the
rule to this:

 [r1: (?x rdf:type ro:RosterEntry), (?x ro:hasSignature ?sig), regex(?sig,
> '(.*) (.*)', ?first, ?last), makeSkolem(?y, ?x), uriConcat('
> http://example.com/ont/roster/people/', ?first, ?last, ?y) -> (?y
> ro:hasFirstName ?first),  (?y ro:hasLastName ?last),  (?y rdf:type
> ro:Person)]


Jena doesn't seem to infer any new nodes.

I tried separating it into another rule:

 [r1: (?x rdf:type ro:RosterEntry), (?x ro:hasSignature ?sig), regex(?sig,
> '(.*) (.*)', ?first, ?last), makeSkolem(?y, ?x) -> (?y ro:hasFirstName
> ?first),  (?y ro:hasLastName ?last),  (?y rdf:type ro:Person)]
>  [r2: (?x rdf:type ro:Person), (?x ro:hasFirstName ?first), (?x
> ro:hasLastName ?last), uriConcat('http://example.com/ont/roster/people/',
> ?first, ?last, ?y) -> print('woot', ?y)]


What is strange is that with the second rule, the inference engine prints
out:

'woot' <http://example.com/ont/roster/people/BobSmith>
'woot' <http://example.com/ont/roster/people/SallyJones>

But, when I listStatements and print out the InfModel,

I get the same node URIs:

1PXx9jabIZ6w9mfO0GygJA== type Person .
> 1PXx9jabIZ6w9mfO0GygJA== hasLastName "Jones" .
> 1PXx9jabIZ6w9mfO0GygJA== hasFirstName "Sally" .
> lOqL7Rx2Lwv5OK6BWD/jSA== type Person .
> lOqL7Rx2Lwv5OK6BWD/jSA== hasLastName "Smith" .
> lOqL7Rx2Lwv5OK6BWD/jSA== hasFirstName "Bob" .


So, does uriConcat not set the node's uri permanently?







On Sun, May 24, 2020 at 6:03 AM Dave Reynolds 
wrote:

> Sorry, only just noticed this question. Responses below:
>
> On 20/05/2020 10:41, Kenneth Keefe wrote:
> > Thanks for all the help so far! I've made some good progress on this
> > example I'm trying to forge. Here are the files for this example:
> >
> > Ontology: https://cioi.iti.illinois.edu/ont/examples/roster.owl
> > Rules: https://cioi.iti.illinois.edu/ont/examples/roster.rules
> >
> > Using this code:
> >
> > OntModel model =
> ModelFactory.*createOntologyModel*(OntModelSpec.*OWL_MEM*);
> >
> > model.read("file:roster.owl");
> >
> > List rules = Rule.*rulesFromURL*("file:roster.rules");
> >
> > Reasoner reasoner = new GenericRuleReasoner(rules);
> >
> > InfModel inf = ModelFactory.*createInfModel*(reasoner, model);
> >
> >
> > printAllStatements(inf);
> >
> > I get this output (I use the LocalName for the predicates and objects for
> > readability):
> >
> > b04230c7-55dc-4e08-92d7-26559c0c478f hasLastName "Smith" .
> > c33de24f-82f1-4aa2-a78e-73201341b274 type Person .
> > c812ff54-30bf-49e7-8e35-3544dad096b7 hasFirstName "Sally" .
> > 16b7a887-2fb9-4bdb-a529-34ca8b3137e4 hasFirstName "Bob" .
> > b31eb7d5-a8ad-469e-ae83-366bdf46fd72 hasLastName "Jones" .
> > 8b46f0c7-4eb2-41e2-8789-8967e8f63eec type Person .
> > http://example.com/ont/roster/ versionIRI .
> > http://example.com/ont/roster/ type Ontology .
> > http://example.com/ont/roster/RosterEntry type Class .
> > http://example.com/ont/roster/bobEntry hasSignature "Bob Smith" .
> > http://example.com/ont/roster/bobEntry type RosterEntry .
> > http://example.com/ont/roster/bobEntry type NamedIndividual .
> > http://example.com/ont/roster/Person type Class .
> > http://example.com/ont/roster/hasLastName range string .
> > http://example.com/ont/roster/hasLastName domain Person .
> > http://example.com/ont/roster/hasLastName type DatatypeProperty .
> > http://example.com/ont/roster/sallyEntry hasSignature "Sally Jones" .
> > http://example.com/ont/roster/sallyEntry type

Re: Help with inference rules

2020-05-24 Thread Dave Reynolds

Sorry, only just noticed this question. Responses below:

On 20/05/2020 10:41, Kenneth Keefe wrote:

Thanks for all the help so far! I've made some good progress on this
example I'm trying to forge. Here are the files for this example:

Ontology: https://cioi.iti.illinois.edu/ont/examples/roster.owl
Rules: https://cioi.iti.illinois.edu/ont/examples/roster.rules

Using this code:

OntModel model = ModelFactory.*createOntologyModel*(OntModelSpec.*OWL_MEM*);

model.read("file:roster.owl");

List rules = Rule.*rulesFromURL*("file:roster.rules");

Reasoner reasoner = new GenericRuleReasoner(rules);

InfModel inf = ModelFactory.*createInfModel*(reasoner, model);


printAllStatements(inf);

I get this output (I use the LocalName for the predicates and objects for
readability):

b04230c7-55dc-4e08-92d7-26559c0c478f hasLastName "Smith" .
c33de24f-82f1-4aa2-a78e-73201341b274 type Person .
c812ff54-30bf-49e7-8e35-3544dad096b7 hasFirstName "Sally" .
16b7a887-2fb9-4bdb-a529-34ca8b3137e4 hasFirstName "Bob" .
b31eb7d5-a8ad-469e-ae83-366bdf46fd72 hasLastName "Jones" .
8b46f0c7-4eb2-41e2-8789-8967e8f63eec type Person .
http://example.com/ont/roster/ versionIRI .
http://example.com/ont/roster/ type Ontology .
http://example.com/ont/roster/RosterEntry type Class .
http://example.com/ont/roster/bobEntry hasSignature "Bob Smith" .
http://example.com/ont/roster/bobEntry type RosterEntry .
http://example.com/ont/roster/bobEntry type NamedIndividual .
http://example.com/ont/roster/Person type Class .
http://example.com/ont/roster/hasLastName range string .
http://example.com/ont/roster/hasLastName domain Person .
http://example.com/ont/roster/hasLastName type DatatypeProperty .
http://example.com/ont/roster/sallyEntry hasSignature "Sally Jones" .
http://example.com/ont/roster/sallyEntry type RosterEntry .
http://example.com/ont/roster/sallyEntry type NamedIndividual .
http://example.com/ont/roster/hasSignature range string .
http://example.com/ont/roster/hasSignature domain RosterEntry .
http://example.com/ont/roster/hasSignature type DatatypeProperty .
http://example.com/ont/roster/hasFirstName range string .
http://example.com/ont/roster/hasFirstName domain Person .
http://example.com/ont/roster/hasFirstName type DatatypeProperty .

Here are my questions:

Focusing on just the Bob Smith entry:

b04230c7-55dc-4e08-92d7-26559c0c478f hasLastName "Smith" .
c33de24f-82f1-4aa2-a78e-73201341b274 type Person .
16b7a887-2fb9-4bdb-a529-34ca8b3137e4 hasFirstName "Bob" .

1. Are these unique ids of anonymous nodes?


Yes.


2. Why are they not identical across these three lines?


Because your ?y variable hasn't been bound in the rule body, each triple 
pattern finds there's no value for ?y and separately treats it as a bNode.


If you want a shared bNode then use makeTemp(?y) in the body (or 
makeSoklem).



3. Is there a way to name these new nodes in the rule? For example, make
the new node http://example.com/ont/roster/people/BobSmith.


Sure, use uriConcat, something like (untested):

   uriConcat('http://example.com/ont/roster/people/', ?first, ?last, 
?y) -> ...


Dave



Thank you!

Ken





On Tue, May 12, 2020 at 1:44 AM Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:


Hi,

I think the rule would be basically

[r1: (?x rdf:type ex:RosterEntry), (?x ex:hasSignature ?sig),
regex(?sig, '(.*) (.*)', ?first, ?last)  -> (?x ex:hasFirstName
?first),  (?x ex:hasLastName ?last),  (?x rdf:type ex:Person) ) ]

Note, it's untested and you have to define your prefix ex: in the rules
file. You might also have to adapt the regex pattern to cover different
white space chars.

On 12.05.20 00:56, Kenneth Keefe wrote:

I am pretty new to using Jena and OWL. I have read many great tutorials
regarding RDF and OWL. The focus of those tutorials has largely been how

to

structure the ontology and define restrictions on properties and such.
However, I have not been able to find good tutorials that explain how
inference is done and how I can define my own inference rules. I'm
wondering if I am simply not searching for the right thing.

Regardless, here is a significant example that I think will really help

me

get started with inference using Jena. I created a minimal example to
enable discussion. Here is a pastebin:  https://pastebin.com/ScTGcbcZ

The ontology has two classes, RosterEntry and Person and three data
properties, Signature (associated with RosterEntry), and FirstName and
LastName (both associated with Person). The example also has two
RosterEntry individuals with signatures of "Bob Smith" and "Sally Jones."

I would like to write a rule that causes Jena to infer the following new
facts:



 http://example.com/ont/roster/Person"; />
 Bob

 Smith

 




 http://example.com/ont/roster/Person"; />
 Sally

 Jones

 


How do I do that? Full answers or nudges in the right direction are both
very welcome. Thank you!

Ken








Re: Help with inference rules

2020-05-20 Thread Kenneth Keefe
Thanks for all the help so far! I've made some good progress on this
example I'm trying to forge. Here are the files for this example:

Ontology: https://cioi.iti.illinois.edu/ont/examples/roster.owl
Rules: https://cioi.iti.illinois.edu/ont/examples/roster.rules

Using this code:

OntModel model = ModelFactory.*createOntologyModel*(OntModelSpec.*OWL_MEM*);

model.read("file:roster.owl");

List rules = Rule.*rulesFromURL*("file:roster.rules");

Reasoner reasoner = new GenericRuleReasoner(rules);

InfModel inf = ModelFactory.*createInfModel*(reasoner, model);


printAllStatements(inf);

I get this output (I use the LocalName for the predicates and objects for
readability):

b04230c7-55dc-4e08-92d7-26559c0c478f hasLastName "Smith" .
c33de24f-82f1-4aa2-a78e-73201341b274 type Person .
c812ff54-30bf-49e7-8e35-3544dad096b7 hasFirstName "Sally" .
16b7a887-2fb9-4bdb-a529-34ca8b3137e4 hasFirstName "Bob" .
b31eb7d5-a8ad-469e-ae83-366bdf46fd72 hasLastName "Jones" .
8b46f0c7-4eb2-41e2-8789-8967e8f63eec type Person .
http://example.com/ont/roster/ versionIRI .
http://example.com/ont/roster/ type Ontology .
http://example.com/ont/roster/RosterEntry type Class .
http://example.com/ont/roster/bobEntry hasSignature "Bob Smith" .
http://example.com/ont/roster/bobEntry type RosterEntry .
http://example.com/ont/roster/bobEntry type NamedIndividual .
http://example.com/ont/roster/Person type Class .
http://example.com/ont/roster/hasLastName range string .
http://example.com/ont/roster/hasLastName domain Person .
http://example.com/ont/roster/hasLastName type DatatypeProperty .
http://example.com/ont/roster/sallyEntry hasSignature "Sally Jones" .
http://example.com/ont/roster/sallyEntry type RosterEntry .
http://example.com/ont/roster/sallyEntry type NamedIndividual .
http://example.com/ont/roster/hasSignature range string .
http://example.com/ont/roster/hasSignature domain RosterEntry .
http://example.com/ont/roster/hasSignature type DatatypeProperty .
http://example.com/ont/roster/hasFirstName range string .
http://example.com/ont/roster/hasFirstName domain Person .
http://example.com/ont/roster/hasFirstName type DatatypeProperty .

Here are my questions:

Focusing on just the Bob Smith entry:

b04230c7-55dc-4e08-92d7-26559c0c478f hasLastName "Smith" .
c33de24f-82f1-4aa2-a78e-73201341b274 type Person .
16b7a887-2fb9-4bdb-a529-34ca8b3137e4 hasFirstName "Bob" .

1. Are these unique ids of anonymous nodes?

2. Why are they not identical across these three lines?

3. Is there a way to name these new nodes in the rule? For example, make
the new node http://example.com/ont/roster/people/BobSmith.

Thank you!

Ken





On Tue, May 12, 2020 at 1:44 AM Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> Hi,
>
> I think the rule would be basically
>
> [r1: (?x rdf:type ex:RosterEntry), (?x ex:hasSignature ?sig),
> regex(?sig, '(.*) (.*)', ?first, ?last)  -> (?x ex:hasFirstName
> ?first),  (?x ex:hasLastName ?last),  (?x rdf:type ex:Person) ) ]
>
> Note, it's untested and you have to define your prefix ex: in the rules
> file. You might also have to adapt the regex pattern to cover different
> white space chars.
>
> On 12.05.20 00:56, Kenneth Keefe wrote:
> > I am pretty new to using Jena and OWL. I have read many great tutorials
> > regarding RDF and OWL. The focus of those tutorials has largely been how
> to
> > structure the ontology and define restrictions on properties and such.
> > However, I have not been able to find good tutorials that explain how
> > inference is done and how I can define my own inference rules. I'm
> > wondering if I am simply not searching for the right thing.
> >
> > Regardless, here is a significant example that I think will really help
> me
> > get started with inference using Jena. I created a minimal example to
> > enable discussion. Here is a pastebin:  https://pastebin.com/ScTGcbcZ
> >
> > The ontology has two classes, RosterEntry and Person and three data
> > properties, Signature (associated with RosterEntry), and FirstName and
> > LastName (both associated with Person). The example also has two
> > RosterEntry individuals with signatures of "Bob Smith" and "Sally Jones."
> >
> > I would like to write a rule that causes Jena to infer the following new
> > facts:
> >
> > 
> >>  >> rdf:resource="http://example.com/ont/roster/Person"; />
> >> Bob
> > Smith
> >
> > 
> >
> >
> > 
> >>  >> rdf:resource="http://example.com/ont/roster/Person"; />
> >> Sally
> > Jones
> >
> > 
> >
> >
> > How do I do that? Full answers or nudges in the right direction are both
> > very welcome. Thank you!
> >
> > Ken
> >
>
>

-- 
---
Ken Keefe
Senior Software Engineer
Information Trust Institute
University of Illinois at Urbana-Champaign
1308 W. Main St.
CSL 225
Urbana, Illinois 61801, USA
Phone: 217-244-3203
Web: https://www.perform.illinois.edu/~kjkeefe
Email: kjke...@illinois.edu


Re: Help with inference rules

2020-05-15 Thread Silvio Domingos
Dear Ken,

I hope this example helps you:

String rules = "[rule1: (?a eg:p ?b) (?b eg:p ?c) -> (?a eg:p ?c)]";
Reasoner reasoner = new GenericRuleReasoner(Rule.parseRules(rules));
reasoner.setDerivationLogging(true);
InfModel inf = ModelFactory.createInfModel(reasoner, rawData);

You can check more here: 
https://jena.apache.org/documentation/inference/index.html

On 2020/05/13 01:28:29, Kenneth Keefe  wrote: 
> When you are working on rules like this with Jena, what tools do you use to
> test? Is there an IDE for interfacing with Jena and building ontologies?
> 
> Thanks,
> Ken
> 
> On Tue, May 12, 2020 at 1:44 AM Lorenz Buehmann <
> buehm...@informatik.uni-leipzig.de> wrote:
> 
> > Hi,
> >
> > I think the rule would be basically
> >
> > [r1: (?x rdf:type ex:RosterEntry), (?x ex:hasSignature ?sig),
> > regex(?sig, '(.*) (.*)', ?first, ?last)  -> (?x ex:hasFirstName
> > ?first),  (?x ex:hasLastName ?last),  (?x rdf:type ex:Person) ) ]
> >
> > Note, it's untested and you have to define your prefix ex: in the rules
> > file. You might also have to adapt the regex pattern to cover different
> > white space chars.
> >
> > On 12.05.20 00:56, Kenneth Keefe wrote:
> > > I am pretty new to using Jena and OWL. I have read many great tutorials
> > > regarding RDF and OWL. The focus of those tutorials has largely been how
> > to
> > > structure the ontology and define restrictions on properties and such.
> > > However, I have not been able to find good tutorials that explain how
> > > inference is done and how I can define my own inference rules. I'm
> > > wondering if I am simply not searching for the right thing.
> > >
> > > Regardless, here is a significant example that I think will really help
> > me
> > > get started with inference using Jena. I created a minimal example to
> > > enable discussion. Here is a pastebin:  https://pastebin.com/ScTGcbcZ
> > >
> > > The ontology has two classes, RosterEntry and Person and three data
> > > properties, Signature (associated with RosterEntry), and FirstName and
> > > LastName (both associated with Person). The example also has two
> > > RosterEntry individuals with signatures of "Bob Smith" and "Sally Jones."
> > >
> > > I would like to write a rule that causes Jena to infer the following new
> > > facts:
> > >
> > > 
> > >>  > >> rdf:resource="http://example.com/ont/roster/Person"; />
> > >> Bob
> > > Smith
> > >
> > > 
> > >
> > >
> > > 
> > >>  > >> rdf:resource="http://example.com/ont/roster/Person"; />
> > >> Sally
> > > Jones
> > >
> > > 
> > >
> > >
> > > How do I do that? Full answers or nudges in the right direction are both
> > > very welcome. Thank you!
> > >
> > > Ken
> > >
> >
> >
> 
> -- 
> ---
> Ken Keefe
> Senior Software Engineer
> Information Trust Institute
> University of Illinois at Urbana-Champaign
> 1308 W. Main St.
> CSL 225
> Urbana, Illinois 61801, USA
> Phone: 217-244-3203
> Web: https://www.perform.illinois.edu/~kjkeefe
> Email: kjke...@illinois.edu
> 


Re: Help with inference rules

2020-05-14 Thread Kenneth Keefe
This is exactly what I'm trying to do. What language is that rule specified
in? How can I utilize it in Jena?

Thanks!

Ken

On Tue, May 12, 2020 at 1:44 AM Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> Hi,
>
> I think the rule would be basically
>
> [r1: (?x rdf:type ex:RosterEntry), (?x ex:hasSignature ?sig),
> regex(?sig, '(.*) (.*)', ?first, ?last)  -> (?x ex:hasFirstName
> ?first),  (?x ex:hasLastName ?last),  (?x rdf:type ex:Person) ) ]
>
> Note, it's untested and you have to define your prefix ex: in the rules
> file. You might also have to adapt the regex pattern to cover different
> white space chars.
>
> On 12.05.20 00:56, Kenneth Keefe wrote:
> > I am pretty new to using Jena and OWL. I have read many great tutorials
> > regarding RDF and OWL. The focus of those tutorials has largely been how
> to
> > structure the ontology and define restrictions on properties and such.
> > However, I have not been able to find good tutorials that explain how
> > inference is done and how I can define my own inference rules. I'm
> > wondering if I am simply not searching for the right thing.
> >
> > Regardless, here is a significant example that I think will really help
> me
> > get started with inference using Jena. I created a minimal example to
> > enable discussion. Here is a pastebin:  https://pastebin.com/ScTGcbcZ
> >
> > The ontology has two classes, RosterEntry and Person and three data
> > properties, Signature (associated with RosterEntry), and FirstName and
> > LastName (both associated with Person). The example also has two
> > RosterEntry individuals with signatures of "Bob Smith" and "Sally Jones."
> >
> > I would like to write a rule that causes Jena to infer the following new
> > facts:
> >
> > 
> >>  >> rdf:resource="http://example.com/ont/roster/Person"; />
> >> Bob
> > Smith
> >
> > 
> >
> >
> > 
> >>  >> rdf:resource="http://example.com/ont/roster/Person"; />
> >> Sally
> > Jones
> >
> > 
> >
> >
> > How do I do that? Full answers or nudges in the right direction are both
> > very welcome. Thank you!
> >
> > Ken
> >
>
>

-- 
---
Ken Keefe
Senior Software Engineer
Information Trust Institute
University of Illinois at Urbana-Champaign
1308 W. Main St.
CSL 225
Urbana, Illinois 61801, USA
Phone: 217-244-3203
Web: https://www.perform.illinois.edu/~kjkeefe
Email: kjke...@illinois.edu


Re: Help with inference rules

2020-05-12 Thread Kenneth Keefe
When you are working on rules like this with Jena, what tools do you use to
test? Is there an IDE for interfacing with Jena and building ontologies?

Thanks,
Ken

On Tue, May 12, 2020 at 1:44 AM Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> Hi,
>
> I think the rule would be basically
>
> [r1: (?x rdf:type ex:RosterEntry), (?x ex:hasSignature ?sig),
> regex(?sig, '(.*) (.*)', ?first, ?last)  -> (?x ex:hasFirstName
> ?first),  (?x ex:hasLastName ?last),  (?x rdf:type ex:Person) ) ]
>
> Note, it's untested and you have to define your prefix ex: in the rules
> file. You might also have to adapt the regex pattern to cover different
> white space chars.
>
> On 12.05.20 00:56, Kenneth Keefe wrote:
> > I am pretty new to using Jena and OWL. I have read many great tutorials
> > regarding RDF and OWL. The focus of those tutorials has largely been how
> to
> > structure the ontology and define restrictions on properties and such.
> > However, I have not been able to find good tutorials that explain how
> > inference is done and how I can define my own inference rules. I'm
> > wondering if I am simply not searching for the right thing.
> >
> > Regardless, here is a significant example that I think will really help
> me
> > get started with inference using Jena. I created a minimal example to
> > enable discussion. Here is a pastebin:  https://pastebin.com/ScTGcbcZ
> >
> > The ontology has two classes, RosterEntry and Person and three data
> > properties, Signature (associated with RosterEntry), and FirstName and
> > LastName (both associated with Person). The example also has two
> > RosterEntry individuals with signatures of "Bob Smith" and "Sally Jones."
> >
> > I would like to write a rule that causes Jena to infer the following new
> > facts:
> >
> > 
> >>  >> rdf:resource="http://example.com/ont/roster/Person"; />
> >> Bob
> > Smith
> >
> > 
> >
> >
> > 
> >>  >> rdf:resource="http://example.com/ont/roster/Person"; />
> >> Sally
> > Jones
> >
> > 
> >
> >
> > How do I do that? Full answers or nudges in the right direction are both
> > very welcome. Thank you!
> >
> > Ken
> >
>
>

-- 
---
Ken Keefe
Senior Software Engineer
Information Trust Institute
University of Illinois at Urbana-Champaign
1308 W. Main St.
CSL 225
Urbana, Illinois 61801, USA
Phone: 217-244-3203
Web: https://www.perform.illinois.edu/~kjkeefe
Email: kjke...@illinois.edu


Re: Help with inference rules

2020-05-11 Thread Lorenz Buehmann
Hi,

I think the rule would be basically

[r1: (?x rdf:type ex:RosterEntry), (?x ex:hasSignature ?sig),
regex(?sig, '(.*) (.*)', ?first, ?last)  -> (?x ex:hasFirstName
?first),  (?x ex:hasLastName ?last),  (?x rdf:type ex:Person) ) ]

Note, it's untested and you have to define your prefix ex: in the rules
file. You might also have to adapt the regex pattern to cover different
white space chars.

On 12.05.20 00:56, Kenneth Keefe wrote:
> I am pretty new to using Jena and OWL. I have read many great tutorials
> regarding RDF and OWL. The focus of those tutorials has largely been how to
> structure the ontology and define restrictions on properties and such.
> However, I have not been able to find good tutorials that explain how
> inference is done and how I can define my own inference rules. I'm
> wondering if I am simply not searching for the right thing.
>
> Regardless, here is a significant example that I think will really help me
> get started with inference using Jena. I created a minimal example to
> enable discussion. Here is a pastebin:  https://pastebin.com/ScTGcbcZ
>
> The ontology has two classes, RosterEntry and Person and three data
> properties, Signature (associated with RosterEntry), and FirstName and
> LastName (both associated with Person). The example also has two
> RosterEntry individuals with signatures of "Bob Smith" and "Sally Jones."
>
> I would like to write a rule that causes Jena to infer the following new
> facts:
>
> 
>> > rdf:resource="http://example.com/ont/roster/Person"; />
>> Bob
> Smith
>
> 
>
>
> 
>> > rdf:resource="http://example.com/ont/roster/Person"; />
>> Sally
> Jones
>
> 
>
>
> How do I do that? Full answers or nudges in the right direction are both
> very welcome. Thank you!
>
> Ken
>



Help with inference rules

2020-05-11 Thread Kenneth Keefe
I am pretty new to using Jena and OWL. I have read many great tutorials
regarding RDF and OWL. The focus of those tutorials has largely been how to
structure the ontology and define restrictions on properties and such.
However, I have not been able to find good tutorials that explain how
inference is done and how I can define my own inference rules. I'm
wondering if I am simply not searching for the right thing.

Regardless, here is a significant example that I think will really help me
get started with inference using Jena. I created a minimal example to
enable discussion. Here is a pastebin:  https://pastebin.com/ScTGcbcZ

The ontology has two classes, RosterEntry and Person and three data
properties, Signature (associated with RosterEntry), and FirstName and
LastName (both associated with Person). The example also has two
RosterEntry individuals with signatures of "Bob Smith" and "Sally Jones."

I would like to write a rule that causes Jena to infer the following new
facts:


>  rdf:resource="http://example.com/ont/roster/Person"; />
> Bob

Smith





>  rdf:resource="http://example.com/ont/roster/Person"; />
> Sally

Jones




How do I do that? Full answers or nudges in the right direction are both
very welcome. Thank you!

Ken


AW: Loading *.rules file to Fuseki server?

2020-03-10 Thread Humm, Bernhard, Prof. Dr.
I start Fuseki with packaged fuseki-server.bat ("java -Xmx1200M -jar
fuseki-server.jar %*").
It definitely considers the config file in folder
C:\apache-jena-fuseki-3.10.0\run\configuration\. When I put some nonsense in
the config file I get an error at server startup.



-Ursprüngliche Nachricht-
Von: Lorenz Buehmann [mailto:buehm...@informatik.uni-leipzig.de] 
Gesendet: Dienstag, 10. März 2020 12:09
An: users@jena.apache.org
Betreff: Re: Loading *.rules file to Fuseki server?

Hi do you start Fuseki with the config file?


It should be

|fuseki-server --config=CONFIG_FILE_HERE|

On 10.03.20 11:45, Humm, Bernhard, Prof. Dr. wrote:
>
> Hello,
>
>  
>
> I would like to load an ontology file *.ttl and a file containing Jena 
> rules *.rules to a Fuseki 3.10.0 server and perform interactive SPARQL 
> queries on http://localhost:3030/
>
> Uploading the *.ttl file via the GUI and executing SPARQL queries on 
> those triples works fine.
>
> Uploading the *.rules file via the GUI results in a parse error on the 
> very first character in the file (“@prefix …”)
>
> Result: *failed* with message "Parse error: [line: 1, col: 1 ] Content 
> ist nicht zulässig in Prolog."
>
>  
>
> I then consulted this post:
>
> https://github.com/jfmunozf/Jena-Fuseki-Reasoner-Inference/wiki/Config
> uring-Apache-Jena-Fuseki-2.4.1-inference-and-reasoning-support-using-S
> PARQL-1.1:-Jena-inference-rules,-RDFS-Entailment-Regimes-and-OWL-reaso
> ning
>
> I followed the instructions and added a configuration file, specifying 
> both *.ttl and *.rules file.
>
>  
>
> :dataset rdf:type ja:RDFDataset ;
>
> rdfs:label "ArtOntology" ;
>
> ja:defaultGraph
>
> [ rdfs:label "ArtOntology" ;
>
> a ja:InfModel ;
>
>  
>
>     #Reference to ontology file
>
>     ja:content [ja:externalContent
>  >
> ] ;
>
>  
>
>     #Disable OWL-based reasoner
>
>     #ja:reasoner [ja:reasonerURL
> <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>] ;
>
>  
>
>     #Disable RDFS-based reasoner
>
>     #ja:reasoner [ja:reasonerURL
> <http://jena.hpl.hp.com/2003/RDFSExptRuleReasoner>] ;
>
>  
>
>     #Enable Jena Rules-based reasoner and we point the location of 
> rules file
>
>     ja:reasoner [
>
>     ja:reasonerURL 
> <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
>
>     ja:rulesFrom
> 
> ;
>
>         ] ;
>
>   ] ;
>
> .
>
>  
>
> However, on Fuseki server startup, the files are not loaded and the 
> specified rules have no effect on SPARQL queries.
>
> How to load the *.rules file to the Fuseki server?
>
>  
>
> Thank you for your help
>
>  
>
>    Bernhard
>
>  
>


smime.p7s
Description: S/MIME cryptographic signature


Re: Loading *.rules file to Fuseki server?

2020-03-10 Thread Lorenz Buehmann
Hi do you start Fuseki with the config file?


It should be

|fuseki-server --config=CONFIG_FILE_HERE|

On 10.03.20 11:45, Humm, Bernhard, Prof. Dr. wrote:
>
> Hello,
>
>  
>
> I would like to load an ontology file *.ttl and a file containing Jena
> rules *.rules to a Fuseki 3.10.0 server and perform interactive SPARQL
> queries on http://localhost:3030/
>
> Uploading the *.ttl file via the GUI and executing SPARQL queries on
> those triples works fine.
>
> Uploading the *.rules file via the GUI results in a parse error on the
> very first character in the file (“@prefix …”)
>
> Result: *failed* with message "Parse error: [line: 1, col: 1 ] Content
> ist nicht zulässig in Prolog."
>
>  
>
> I then consulted this post:
>
> https://github.com/jfmunozf/Jena-Fuseki-Reasoner-Inference/wiki/Configuring-Apache-Jena-Fuseki-2.4.1-inference-and-reasoning-support-using-SPARQL-1.1:-Jena-inference-rules,-RDFS-Entailment-Regimes-and-OWL-reasoning
>
> I followed the instructions and added a configuration file, specifying
> both *.ttl and *.rules file.
>
>  
>
> :dataset rdf:type ja:RDFDataset ;
>
> rdfs:label "ArtOntology" ;
>
> ja:defaultGraph
>
> [ rdfs:label "ArtOntology" ;
>
> a ja:InfModel ;
>
>  
>
>     #Reference to ontology file
>
>     ja:content [ja:externalContent
> 
> ] ;
>
>  
>
>     #Disable OWL-based reasoner
>
>     #ja:reasoner [ja:reasonerURL
> <http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>] ;
>
>  
>
>     #Disable RDFS-based reasoner
>
>     #ja:reasoner [ja:reasonerURL
> <http://jena.hpl.hp.com/2003/RDFSExptRuleReasoner>] ;
>
>  
>
>     #Enable Jena Rules-based reasoner and we point the location of
> rules file
>
>     ja:reasoner [
>
>     ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
>
>     ja:rulesFrom
> 
> ;  
>
>         ] ;
>
>   ] ;
>
> .
>
>  
>
> However, on Fuseki server startup, the files are not loaded and the
> specified rules have no effect on SPARQL queries.
>
> How to load the *.rules file to the Fuseki server?
>
>  
>
> Thank you for your help
>
>  
>
>    Bernhard
>
>  
>


Loading *.rules file to Fuseki server?

2020-03-10 Thread Humm, Bernhard, Prof. Dr.
Hello,

 

I would like to load an ontology file *.ttl and a file containing Jena rules
*.rules to a Fuseki 3.10.0 server and perform interactive SPARQL queries on
http://localhost:3030/ 

Uploading the *.ttl file via the GUI and executing SPARQL queries on those
triples works fine.

Uploading the *.rules file via the GUI results in a parse error on the very
first character in the file (“@prefix …”)

Result: failed with message "Parse error: [line: 1, col: 1 ] Content ist
nicht zulässig in Prolog."

 

I then consulted this post:

 
<https://github.com/jfmunozf/Jena-Fuseki-Reasoner-Inference/wiki/Configuring
-Apache-Jena-Fuseki-2.4.1-inference-and-reasoning-support-using-SPARQL-1.1:-
Jena-inference-rules,-RDFS-Entailment-Regimes-and-OWL-reasoning>
https://github.com/jfmunozf/Jena-Fuseki-Reasoner-Inference/wiki/Configuring-
Apache-Jena-Fuseki-2.4.1-inference-and-reasoning-support-using-SPARQL-1.1:-J
ena-inference-rules,-RDFS-Entailment-Regimes-and-OWL-reasoning

I followed the instructions and added a configuration file, specifying both
*.ttl and *.rules file. 

 

:dataset rdf:type ja:RDFDataset ;

rdfs:label "ArtOntology" ;

ja:defaultGraph

[ rdfs:label "ArtOntology" ;

a ja:InfModel ;

 

#Reference to ontology file

ja:content [ja:externalContent
 ] ;

 

#Disable OWL-based reasoner

#ja:reasoner [ja:reasonerURL
<http://jena.hpl.hp.com/2003/OWLFBRuleReasoner>] ;

 

#Disable RDFS-based reasoner

#ja:reasoner [ja:reasonerURL
<http://jena.hpl.hp.com/2003/RDFSExptRuleReasoner>] ;

 

#Enable Jena Rules-based reasoner and we point the location of rules
file

ja:reasoner [

ja:reasonerURL <http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;

ja:rulesFrom
 ;


] ; 

  ] ;

.

 

However, on Fuseki server startup, the files are not loaded and the
specified rules have no effect on SPARQL queries.

How to load the *.rules file to the Fuseki server?

 

Thank you for your help

 

   Bernhard 

 



smime.p7s
Description: S/MIME cryptographic signature


Re: is it possible to combine kleene paths and rules?

2019-09-05 Thread Dave Reynolds

Hi James,

On 05/09/2019 09:19, james anderson wrote:

good morning;


On 2019-09-05, at 09:46:27, Dave Reynolds  wrote:

Hi,

In principle, I could imagine it would be possible to allow property paths in 
the predicate position in body patterns.


yes, that i would expect.
i am interested in the other variant: where the effect of a predicate is 
defined b a rule.


Sorry don't follow what you have in mind here. However, that likely 
means that the answer ("not aware of any work on this") doesn't change :)


Cheers,
Dave


Personally I'm not aware of any work like this.

Dave

On 03/09/2019 09:40, James Anderson wrote:

good morning;
has there been any experience combining the general purpose rule engine with 
arbitrary length property paths?
when i read the jena documentation, i fail to find “path" on the page
 https://jena.apache.org/documentation/query/property_paths.html
and neither does either “rule" or “reason" appear on
 https://jena.apache.org/documentation/inference/
but the descriptions do leave the impression that it should be possible to 
combine the two.
are there any well known examples?
best regards, from berlin,




Re: is it possible to combine kleene paths and rules?

2019-09-05 Thread james anderson
good morning;

> On 2019-09-05, at 09:46:27, Dave Reynolds  wrote:
> 
> Hi,
> 
> In principle, I could imagine it would be possible to allow property paths in 
> the predicate position in body patterns.

yes, that i would expect.
i am interested in the other variant: where the effect of a predicate is 
defined b a rule.

> 
> Personally I'm not aware of any work like this.
> 
> Dave
> 
> On 03/09/2019 09:40, James Anderson wrote:
>> good morning;
>> has there been any experience combining the general purpose rule engine with 
>> arbitrary length property paths?
>> when i read the jena documentation, i fail to find “path" on the page
>> https://jena.apache.org/documentation/query/property_paths.html
>> and neither does either “rule" or “reason" appear on
>> https://jena.apache.org/documentation/inference/
>> but the descriptions do leave the impression that it should be possible to 
>> combine the two.
>> are there any well known examples?
>> best regards, from berlin,



Re: is it possible to combine kleene paths and rules?

2019-09-05 Thread Dave Reynolds

Hi,

In principle, I could imagine it would be possible to allow property 
paths in the predicate position in body patterns.


Personally I'm not aware of any work like this.

Dave

On 03/09/2019 09:40, James Anderson wrote:

good morning;

has there been any experience combining the general purpose rule engine with 
arbitrary length property paths?


when i read the jena documentation, i fail to find “path" on the page

 https://jena.apache.org/documentation/query/property_paths.html

and neither does either “rule" or “reason" appear on

 https://jena.apache.org/documentation/inference/

but the descriptions do leave the impression that it should be possible to 
combine the two.
are there any well known examples?

best regards, from berlin,



is it possible to combine kleene paths and rules?

2019-09-03 Thread James Anderson
good morning;

has there been any experience combining the general purpose rule engine with 
arbitrary length property paths?


when i read the jena documentation, i fail to find “path" on the page

https://jena.apache.org/documentation/query/property_paths.html

and neither does either “rule" or “reason" appear on

https://jena.apache.org/documentation/inference/

but the descriptions do leave the impression that it should be possible to 
combine the two.
are there any well known examples?

best regards, from berlin,



RE: Rules and 'on the fly' aggregate values

2019-07-25 Thread Pierre Grenon
Hey,

I think so --- unless I don’t understand the ‘CONSTRUCT query on an inference 
model’ suggestion. This is after all what I understand spin rules would do in 
say Virtuoso. But this is the essence of the dilemma.

Suppose I’m interested in higher level queries where these aggregations have 
been turned to facts. I may want to use rules to derive aggregated values 
instead of having to run preliminary queries. If the computed values need to be 
stored in named graphs for non-monotonicity reasons, then, in effect, I’m not 
sure where the edge is. Also, it brings about the question of how to keep track 
of these graphs.

If queries need to be run to do this population, I suppose it still remains an 
external engine that does the querying and insert then (not going to do this by 
hand). It just sounds like a lot of machinery. (For the records, I don’t 
believe that the value in SPAQRL is to do numerical aggregation, but in 
practice the request arises…)

A bit non-conclusive on my end but thanks for the input.

With many thanks and best regards,
Pierre

THIS E-MAIL MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION. 
IF YOU ARE NOT THE INTENDED RECIPIENT (OR HAVE RECEIVED THIS E-MAIL 
IN ERROR) PLEASE NOTIFY THE SENDER IMMEDIATELY AND DESTROY THIS 
E-MAIL. ANY UNAUTHORISED COPYING, DISCLOSURE OR DISTRIBUTION OF THE 
MATERIAL IN THIS E-MAIL IS STRICTLY FORBIDDEN. 

IN ACCORDANCE WITH MIFID II RULES ON INDUCEMENTS, THE FIRM'S EMPLOYEES 
MAY ATTEND CORPORATE ACCESS EVENTS (DEFINED IN THE FCA HANDBOOK AS 
"THE SERVICE OF ARRANGING OR BRINGING ABOUT CONTACT BETWEEN AN INVESTMENT 
MANAGER AND AN ISSUER OR POTENTIAL ISSUER"). DURING SUCH MEETINGS, THE 
FIRM'S EMPLOYEES MAY ON NO ACCOUNT BE IN RECEIPT OF INSIDE INFORMATION 
(AS DESCRIBED IN ARTICLE 7 OF THE MARKET ABUSE REGULATION (EU) NO 596/2014). 
(https://www.handbook.fca.org.uk/handbook/glossary/G3532m.html)
COMPANIES WHO DISCLOSE INSIDE INFORMATION ARE IN BREACH OF REGULATION 
AND MUST IMMEDIATELY AND CLEARLY NOTIFY ALL ATTENDEES. FOR INFORMATION 
ON THE FIRM'S POLICY IN RELATION TO ITS PARTICIPATION IN MARKET SOUNDINGS, 
PLEASE SEE https://www.horizon-asset.co.uk/market-soundings/. 

HORIZON ASSET LLP IS AUTHORISED AND REGULATED 
BY THE FINANCIAL CONDUCT AUTHORITY.


From: Lorenz Buehmann [mailto:buehm...@informatik.uni-leipzig.de]
Sent: 25 July 2019 10:44
To: users@jena.apache.org
Subject: Re: Rules and 'on the fly' aggregate values

Can't you simply use any any CONSTRUCT query on an inference model? Or
use an INSERT query to write it to a graph? Indeed bot only if you're
producing proper RDF triples.

On 25.07.19 10:36, Pierre Grenon wrote:
> Hi,
>
> Quick search for 'rule aggregate' in mail archives returns 3 thread results. 
> The only decisive statement seems to be Dave's 3 yo:
>
> """
> Short answer on rules is don't use them for this. Something like "sum of
> all invoice items present" is a non-monotonic operation and JenaRules
> are really not suited to this. [...]
> """
>
> https://lists.apache.org/thread.html/40ed40686d6244d3ebc0dfe5163e052b3dba2d41358b5f78f1c81347@<https://lists.apache.org/thread.html/40ed40686d6244d3ebc0dfe5163e052b3dba2d41358b5f78f1c81347@>
>
> Is this still the valid answer? If so, what is the recommendation to perform 
> and persist aggregation for data maintained using Jena?
>
> To pull non aggregate query results and do aggregation within an external 
> application? Write back transitory results to named graphs?
>
> I am not sure whether there may be documentation on this since that I may 
> have missed, if so apologies and thanks for the pointer.
>
> With many thanks and kind regards,
> Pierre
>
> THIS E-MAIL MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION.
> IF YOU ARE NOT THE INTENDED RECIPIENT (OR HAVE RECEIVED THIS E-MAIL
> IN ERROR) PLEASE NOTIFY THE SENDER IMMEDIATELY AND DESTROY THIS
> E-MAIL. ANY UNAUTHORISED COPYING, DISCLOSURE OR DISTRIBUTION OF THE
> MATERIAL IN THIS E-MAIL IS STRICTLY FORBIDDEN.
>
> IN ACCORDANCE WITH MIFID II RULES ON INDUCEMENTS, THE FIRM'S EMPLOYEES
> MAY ATTEND CORPORATE ACCESS EVENTS (DEFINED IN THE FCA HANDBOOK AS
> "THE SERVICE OF ARRANGING OR BRINGING ABOUT CONTACT BETWEEN AN INVESTMENT
> MANAGER AND AN ISSUER OR POTENTIAL ISSUER"). DURING SUCH MEETINGS, THE
> FIRM'S EMPLOYEES MAY ON NO ACCOUNT BE IN RECEIPT OF INSIDE INFORMATION
> (AS DESCRIBED IN ARTICLE 7 OF THE MARKET ABUSE REGULATION (EU) NO 596/2014).
> (https://www.handbook.fca.org.uk/handbook/glossary/G3532m.html<https://www.handbook.fca.org.uk/handbook/glossary/G3532m.html>)
> COMPANIES WHO DISCLOSE INSIDE INFORMATION ARE IN BREACH OF REGULATION
> AND MUST IMMEDIATELY AND CLEARLY NOTIFY ALL ATTENDEES. FOR INFORMATION
> ON THE FIRM'S POLICY IN RELATION TO ITS PARTICIPATION IN MARKET SOUNDINGS,
> PLEASE SEE 
> https://www.horizon-asset.co.uk/market-soundings/<https://www.horizon-asset.co.uk/market-soundings/>.
>
> HORIZON ASSET LLP IS AUTHORISED AND REGULATED
> BY THE FINANCIAL CONDUCT AUTHORITY.
>
>
>


Re: Rules and 'on the fly' aggregate values

2019-07-25 Thread Lorenz Buehmann
Can't you simply use any any CONSTRUCT query on an inference model? Or
use an INSERT query to write it to a graph? Indeed bot only if you're
producing proper RDF triples.

On 25.07.19 10:36, Pierre Grenon wrote:
> Hi, 
>
> Quick search for 'rule aggregate' in mail archives returns 3 thread results. 
> The only decisive statement seems to be Dave's 3 yo: 
>
> """
> Short answer on rules is don't use them for this. Something like "sum of 
> all invoice items present" is a non-monotonic operation and JenaRules 
> are really not suited to this. [...]
> """
>
> https://lists.apache.org/thread.html/40ed40686d6244d3ebc0dfe5163e052b3dba2d41358b5f78f1c81347@%3Cusers.jena.apache.org%3E
>
> Is this still the valid answer? If so, what is the recommendation to perform 
> and persist aggregation for data maintained using Jena? 
>
> To pull non aggregate query results and do aggregation within an external 
> application? Write back transitory results to named graphs? 
>
> I am not sure whether there may be documentation on this since that I may 
> have missed, if so apologies and thanks for the pointer. 
>
> With many thanks and kind regards, 
> Pierre
>
> THIS E-MAIL MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION. 
> IF YOU ARE NOT THE INTENDED RECIPIENT (OR HAVE RECEIVED THIS E-MAIL 
> IN ERROR) PLEASE NOTIFY THE SENDER IMMEDIATELY AND DESTROY THIS 
> E-MAIL. ANY UNAUTHORISED COPYING, DISCLOSURE OR DISTRIBUTION OF THE 
> MATERIAL IN THIS E-MAIL IS STRICTLY FORBIDDEN. 
>
> IN ACCORDANCE WITH MIFID II RULES ON INDUCEMENTS, THE FIRM'S EMPLOYEES 
> MAY ATTEND CORPORATE ACCESS EVENTS (DEFINED IN THE FCA HANDBOOK AS 
> "THE SERVICE OF ARRANGING OR BRINGING ABOUT CONTACT BETWEEN AN INVESTMENT 
> MANAGER AND AN ISSUER OR POTENTIAL ISSUER"). DURING SUCH MEETINGS, THE 
> FIRM'S EMPLOYEES MAY ON NO ACCOUNT BE IN RECEIPT OF INSIDE INFORMATION 
> (AS DESCRIBED IN ARTICLE 7 OF THE MARKET ABUSE REGULATION (EU) NO 596/2014). 
> (https://www.handbook.fca.org.uk/handbook/glossary/G3532m.html)
> COMPANIES WHO DISCLOSE INSIDE INFORMATION ARE IN BREACH OF REGULATION 
> AND MUST IMMEDIATELY AND CLEARLY NOTIFY ALL ATTENDEES. FOR INFORMATION 
> ON THE FIRM'S POLICY IN RELATION TO ITS PARTICIPATION IN MARKET SOUNDINGS, 
> PLEASE SEE https://www.horizon-asset.co.uk/market-soundings/. 
>
> HORIZON ASSET LLP IS AUTHORISED AND REGULATED 
> BY THE FINANCIAL CONDUCT AUTHORITY.
>
>
>


Rules and 'on the fly' aggregate values

2019-07-25 Thread Pierre Grenon
Hi, 

Quick search for 'rule aggregate' in mail archives returns 3 thread results. 
The only decisive statement seems to be Dave's 3 yo: 

"""
Short answer on rules is don't use them for this. Something like "sum of 
all invoice items present" is a non-monotonic operation and JenaRules 
are really not suited to this. [...]
"""

https://lists.apache.org/thread.html/40ed40686d6244d3ebc0dfe5163e052b3dba2d41358b5f78f1c81347@%3Cusers.jena.apache.org%3E

Is this still the valid answer? If so, what is the recommendation to perform 
and persist aggregation for data maintained using Jena? 

To pull non aggregate query results and do aggregation within an external 
application? Write back transitory results to named graphs? 

I am not sure whether there may be documentation on this since that I may have 
missed, if so apologies and thanks for the pointer. 

With many thanks and kind regards, 
Pierre

THIS E-MAIL MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION. 
IF YOU ARE NOT THE INTENDED RECIPIENT (OR HAVE RECEIVED THIS E-MAIL 
IN ERROR) PLEASE NOTIFY THE SENDER IMMEDIATELY AND DESTROY THIS 
E-MAIL. ANY UNAUTHORISED COPYING, DISCLOSURE OR DISTRIBUTION OF THE 
MATERIAL IN THIS E-MAIL IS STRICTLY FORBIDDEN. 

IN ACCORDANCE WITH MIFID II RULES ON INDUCEMENTS, THE FIRM'S EMPLOYEES 
MAY ATTEND CORPORATE ACCESS EVENTS (DEFINED IN THE FCA HANDBOOK AS 
"THE SERVICE OF ARRANGING OR BRINGING ABOUT CONTACT BETWEEN AN INVESTMENT 
MANAGER AND AN ISSUER OR POTENTIAL ISSUER"). DURING SUCH MEETINGS, THE 
FIRM'S EMPLOYEES MAY ON NO ACCOUNT BE IN RECEIPT OF INSIDE INFORMATION 
(AS DESCRIBED IN ARTICLE 7 OF THE MARKET ABUSE REGULATION (EU) NO 596/2014). 
(https://www.handbook.fca.org.uk/handbook/glossary/G3532m.html)
COMPANIES WHO DISCLOSE INSIDE INFORMATION ARE IN BREACH OF REGULATION 
AND MUST IMMEDIATELY AND CLEARLY NOTIFY ALL ATTENDEES. FOR INFORMATION 
ON THE FIRM'S POLICY IN RELATION TO ITS PARTICIPATION IN MARKET SOUNDINGS, 
PLEASE SEE https://www.horizon-asset.co.uk/market-soundings/. 

HORIZON ASSET LLP IS AUTHORISED AND REGULATED 
BY THE FINANCIAL CONDUCT AUTHORITY.




Fw: Import rules from another GenericRuleReasoner file

2019-07-05 Thread Laura Morales
@include .

reference: https://jena.apache.org/documentation/inference/#rules




> Sent: Friday, July 05, 2019 at 1:21 PM
> From: "Laura Morales" 
> To: jena-users-ml 
> Subject: Import rules from another GenericRuleReasoner file
>
> I have a file that contains rules for a GenericRuleReasoner. Is it possible 
> to import another file containing more rules, from the former?
>


Import rules from another GenericRuleReasoner file

2019-07-05 Thread Laura Morales
I have a file that contains rules for a GenericRuleReasoner. Is it possible to 
import another file containing more rules, from the former?



Re: Documentation/tutorial on using dates in Jena rules with GenericRuleReasoner

2019-06-03 Thread Dave Reynolds

On 03/06/2019 16:36, Pierre Grenon wrote:

So can I just edit

\jena-core\src\main\java\org\apache\jena\reasoner\rulesys\ BuiltinRegistry.java

?

Or is that too hackish?


Definitely too hackish.

After some google searching it I see some old mentions that fuseki 
loadClass will call any public static void init() method on the class 
you load. If that's still true then you should be able to put the


BuiltinRegistry.theRegistry.register(...)

call(s) in such an init method.

Dave


Thanks ,
Pierre

THIS E-MAIL MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION.
IF YOU ARE NOT THE INTENDED RECIPIENT (OR HAVE RECEIVED THIS E-MAIL
IN ERROR) PLEASE NOTIFY THE SENDER IMMEDIATELY AND DESTROY THIS
E-MAIL. ANY UNAUTHORISED COPYING, DISCLOSURE OR DISTRIBUTION OF THE
MATERIAL IN THIS E-MAIL IS STRICTLY FORBIDDEN.

IN ACCORDANCE WITH MIFID II RULES ON INDUCEMENTS, THE FIRM'S EMPLOYEES
MAY ATTEND CORPORATE ACCESS EVENTS (DEFINED IN THE FCA HANDBOOK AS
"THE SERVICE OF ARRANGING OR BRINGING ABOUT CONTACT BETWEEN AN INVESTMENT
MANAGER AND AN ISSUER OR POTENTIAL ISSUER"). DURING SUCH MEETINGS, THE
FIRM'S EMPLOYEES MAY ON NO ACCOUNT BE IN RECEIPT OF INSIDE INFORMATION
(AS DESCRIBED IN ARTICLE 7 OF THE MARKET ABUSE REGULATION (EU) NO 596/2014).
(https://www.handbook.fca.org.uk/handbook/glossary/G3532m.html)
COMPANIES WHO DISCLOSE INSIDE INFORMATION ARE IN BREACH OF REGULATION
AND MUST IMMEDIATELY AND CLEARLY NOTIFY ALL ATTENDEES. FOR INFORMATION
ON THE FIRM'S POLICY IN RELATION TO ITS PARTICIPATION IN MARKET SOUNDINGS,
PLEASE SEE https://www.horizon-asset.co.uk/market-soundings/.

HORIZON ASSET LLP IS AUTHORISED AND REGULATED
BY THE FINANCIAL CONDUCT AUTHORITY.


From: Dave Reynolds [mailto:dave.e.reyno...@gmail.com]
Sent: 03 June 2019 11:17
To: users@jena.apache.org
Subject: Re: Documentation/tutorial on using dates in Jena rules with 
GenericRuleReasoner

Hi Pierre,

I'm afraid I've lost track of what you are tying to do. Originally it
seemed to be a problem running comparisons on date time values but
Lorenz has already answered that.

In terms on writing your own new Builtins, then before you can use a new
rule Builtin it needs to be registered. That's what the line:

BuiltinRegistry.theRegistry.register( new StringEqualIgnoreCase() )

was doing in my (non-fuseki) example.

If you need your new builtin to run within fuseki then you would need
some way to trigger such registration code. No doubt that's possible but
not something I've any first hand knowledge of.

By the way, for simply getting code loaded into fuseki you don't need to
repack the jar. Just add your new jar to the classpath and use the
ja:loadClass function to get your class loaded when fuseki starts up.
See last example in:

https://jena.apache.org/documentation/fuseki2/fuseki-configuration.html

Dave

On 03/06/2019 07:01, Pierre Grenon wrote:

Hi Dave,

Executive summary:

I'm not a java coder. I did what I could to try to do this using fuseki.

I get this:
[2019-05-31 18:47:30] Functor WARN Invoking undefined functor testBuilt in r1

I understand this may be related to RuleContext. I don't understand any further.
Details below.

With many thanks,
Pierre

Details ---

1. I unzipped my fuseki-server.jar

2. I placed the code below into a ..\rulesys\testBuilt.java as


package org.apache.jena.reasoner.rulesys.builtins;


import org.apache.jena.graph.* ;
import org.apache.jena.reasoner.rulesys.* ;

/**
* Tests if the first argument is less than the second.
*/

class testBuilt extends BaseBuiltin implements Builtin {
public String getName() {
return "testBuilt";
}

@Override
public int getArgLength() {
return 2;
}

@Override
public boolean bodyCall(Node[] args, int length, RuleContext context) {
checkArgs(length, context);
Node n1 = getArg(0, args, context);
Node n2 = getArg(1, args, context);
if (n1.isLiteral() && n1.isLiteral()) {
return n1.getLiteralLexicalForm().equalsIgnoreCase(
n2.getLiteralLexicalForm() );
} else {
return false;
}
}
}



3. Compiled that:

C:\dev\apache-jena-fuseki-3.10.0\woot>javac 
org\apache\jena\reasoner\rulesys\builtins\testBuilt.java

4. Jar-ed the whole thing back

C:\dev\apache-jena-fuseki-3.10.0\woot>jar cmvf 
fuseki-server\META-INF\MANIFEST.MF fuseki-server.jar -C fuseki-server/ .

5. Replaced my fuseki-server.jar

6. Created a rule file


@prefix ns: <http://test.org#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

[r1:
(?x ns:p ?pl)
(?x ns:q ?ql)
testBuilt(?pl, ?ql)
->
(?x ns:r 'equal')
]


7. Created a dataset file


@prefix ns: <http://test.org#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/200

RE: Documentation/tutorial on using dates in Jena rules with GenericRuleReasoner

2019-06-03 Thread Pierre Grenon
So can I just edit 

\jena-core\src\main\java\org\apache\jena\reasoner\rulesys\ BuiltinRegistry.java

?

Or is that too hackish?

Thanks , 
Pierre

THIS E-MAIL MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION. 
IF YOU ARE NOT THE INTENDED RECIPIENT (OR HAVE RECEIVED THIS E-MAIL 
IN ERROR) PLEASE NOTIFY THE SENDER IMMEDIATELY AND DESTROY THIS 
E-MAIL. ANY UNAUTHORISED COPYING, DISCLOSURE OR DISTRIBUTION OF THE 
MATERIAL IN THIS E-MAIL IS STRICTLY FORBIDDEN. 

IN ACCORDANCE WITH MIFID II RULES ON INDUCEMENTS, THE FIRM'S EMPLOYEES 
MAY ATTEND CORPORATE ACCESS EVENTS (DEFINED IN THE FCA HANDBOOK AS 
"THE SERVICE OF ARRANGING OR BRINGING ABOUT CONTACT BETWEEN AN INVESTMENT 
MANAGER AND AN ISSUER OR POTENTIAL ISSUER"). DURING SUCH MEETINGS, THE 
FIRM'S EMPLOYEES MAY ON NO ACCOUNT BE IN RECEIPT OF INSIDE INFORMATION 
(AS DESCRIBED IN ARTICLE 7 OF THE MARKET ABUSE REGULATION (EU) NO 596/2014). 
(https://www.handbook.fca.org.uk/handbook/glossary/G3532m.html)
COMPANIES WHO DISCLOSE INSIDE INFORMATION ARE IN BREACH OF REGULATION 
AND MUST IMMEDIATELY AND CLEARLY NOTIFY ALL ATTENDEES. FOR INFORMATION 
ON THE FIRM'S POLICY IN RELATION TO ITS PARTICIPATION IN MARKET SOUNDINGS, 
PLEASE SEE https://www.horizon-asset.co.uk/market-soundings/. 

HORIZON ASSET LLP IS AUTHORISED AND REGULATED 
BY THE FINANCIAL CONDUCT AUTHORITY.


From: Dave Reynolds [mailto:dave.e.reyno...@gmail.com] 
Sent: 03 June 2019 11:17
To: users@jena.apache.org
Subject: Re: Documentation/tutorial on using dates in Jena rules with 
GenericRuleReasoner

Hi Pierre,

I'm afraid I've lost track of what you are tying to do. Originally it 
seemed to be a problem running comparisons on date time values but 
Lorenz has already answered that.

In terms on writing your own new Builtins, then before you can use a new 
rule Builtin it needs to be registered. That's what the line:

BuiltinRegistry.theRegistry.register( new StringEqualIgnoreCase() )

was doing in my (non-fuseki) example.

If you need your new builtin to run within fuseki then you would need 
some way to trigger such registration code. No doubt that's possible but 
not something I've any first hand knowledge of.

By the way, for simply getting code loaded into fuseki you don't need to 
repack the jar. Just add your new jar to the classpath and use the 
ja:loadClass function to get your class loaded when fuseki starts up. 
See last example in:

https://jena.apache.org/documentation/fuseki2/fuseki-configuration.html

Dave

On 03/06/2019 07:01, Pierre Grenon wrote:
> Hi Dave,
> 
> Executive summary:
> 
> I'm not a java coder. I did what I could to try to do this using fuseki.
> 
> I get this:
> [2019-05-31 18:47:30] Functor WARN Invoking undefined functor testBuilt in r1
> 
> I understand this may be related to RuleContext. I don't understand any 
> further.
> Details below.
> 
> With many thanks,
> Pierre
> 
> Details ---
> 
> 1. I unzipped my fuseki-server.jar
> 
> 2. I placed the code below into a ..\rulesys\testBuilt.java as
> 
> 
> package org.apache.jena.reasoner.rulesys.builtins;
> 
> 
> import org.apache.jena.graph.* ;
> import org.apache.jena.reasoner.rulesys.* ;
> 
> /**
> * Tests if the first argument is less than the second.
> */
> 
> class testBuilt extends BaseBuiltin implements Builtin {
> public String getName() {
> return "testBuilt";
> }
> 
> @Override
> public int getArgLength() {
> return 2;
> }
> 
> @Override
> public boolean bodyCall(Node[] args, int length, RuleContext context) {
> checkArgs(length, context);
> Node n1 = getArg(0, args, context);
> Node n2 = getArg(1, args, context);
> if (n1.isLiteral() && n1.isLiteral()) {
> return n1.getLiteralLexicalForm().equalsIgnoreCase(
> n2.getLiteralLexicalForm() );
> } else {
> return false;
> }
> }
> }
> 
>  
> 
> 3. Compiled that:
> 
> C:\dev\apache-jena-fuseki-3.10.0\woot>javac 
> org\apache\jena\reasoner\rulesys\builtins\testBuilt.java
> 
> 4. Jar-ed the whole thing back
> 
> C:\dev\apache-jena-fuseki-3.10.0\woot>jar cmvf 
> fuseki-server\META-INF\MANIFEST.MF fuseki-server.jar -C fuseki-server/ .
> 
> 5. Replaced my fuseki-server.jar
> 
> 6. Created a rule file
> 
> 
> @prefix ns: <http://test.org#> .
> @prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
> @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
> 
> [r1:
> (?x ns:p ?pl)
> (?x ns:q ?ql)
> testBuilt(?pl, ?ql)
> ->
> (?x ns:r 'equal')
> ]
> 
> 
> 7. Created a dataset file
> 
> 
> @prefix ns: <http://test.org#> .
> @prefix owl: <http://www.w3.org/2002/07/owl#> .
> @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
> @prefix xml: <http:/

RE: Documentation/tutorial on using dates in Jena rules with GenericRuleReasoner

2019-06-03 Thread Pierre Grenon
Thanks, Dave.

 PREAMBLE 

For memory and context -- I am on a quest... it was two-pronged

- Lorenz helped me work out the rule and config using an existing built in. 
That bit is closed.

- I'm pursuing 

"a. Anybody is a taker to hold me by the hand and use this thread to come 
up with a complete cycle for making a new built in and adding it to my fuseki? 
If somebody has the time to do this---and I’m happy that it takes what it 
takes, I can’t on my end make it a high priority--, we could reuse the thread 
for the purpose of a detailed how-to for noobs like me."

I know you said you didn't have time to do this. I've followed this path using 
the old example of a built in you gave. So now my roadmap is: 

- get a custom built in to work in fuseki (on now)
- work out built in with dates (cherry on the cake) 



So I have to figure: 

- How to register new built in in fuseki (but how does fuseki registers them at 
all then?). I thought that if I packed the class in the jar it was enough to 
ensure the registration. I'll start a new thread for this I suppose.

Thank you for the ja:loadClass, I will try this, it should allow making the 
registration . 

Thank you very much, 
Pierre

THIS E-MAIL MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION. 
IF YOU ARE NOT THE INTENDED RECIPIENT (OR HAVE RECEIVED THIS E-MAIL 
IN ERROR) PLEASE NOTIFY THE SENDER IMMEDIATELY AND DESTROY THIS 
E-MAIL. ANY UNAUTHORISED COPYING, DISCLOSURE OR DISTRIBUTION OF THE 
MATERIAL IN THIS E-MAIL IS STRICTLY FORBIDDEN. 

IN ACCORDANCE WITH MIFID II RULES ON INDUCEMENTS, THE FIRM'S EMPLOYEES 
MAY ATTEND CORPORATE ACCESS EVENTS (DEFINED IN THE FCA HANDBOOK AS 
"THE SERVICE OF ARRANGING OR BRINGING ABOUT CONTACT BETWEEN AN INVESTMENT 
MANAGER AND AN ISSUER OR POTENTIAL ISSUER"). DURING SUCH MEETINGS, THE 
FIRM'S EMPLOYEES MAY ON NO ACCOUNT BE IN RECEIPT OF INSIDE INFORMATION 
(AS DESCRIBED IN ARTICLE 7 OF THE MARKET ABUSE REGULATION (EU) NO 596/2014). 
(https://www.handbook.fca.org.uk/handbook/glossary/G3532m.html)
COMPANIES WHO DISCLOSE INSIDE INFORMATION ARE IN BREACH OF REGULATION 
AND MUST IMMEDIATELY AND CLEARLY NOTIFY ALL ATTENDEES. FOR INFORMATION 
ON THE FIRM'S POLICY IN RELATION TO ITS PARTICIPATION IN MARKET SOUNDINGS, 
PLEASE SEE https://www.horizon-asset.co.uk/market-soundings/. 

HORIZON ASSET LLP IS AUTHORISED AND REGULATED 
BY THE FINANCIAL CONDUCT AUTHORITY.


From: Dave Reynolds [mailto:dave.e.reyno...@gmail.com] 
Sent: 03 June 2019 11:17
To: users@jena.apache.org
Subject: Re: Documentation/tutorial on using dates in Jena rules with 
GenericRuleReasoner

Hi Pierre,

I'm afraid I've lost track of what you are tying to do. Originally it 
seemed to be a problem running comparisons on date time values but 
Lorenz has already answered that.

In terms on writing your own new Builtins, then before you can use a new 
rule Builtin it needs to be registered. That's what the line:

BuiltinRegistry.theRegistry.register( new StringEqualIgnoreCase() )

was doing in my (non-fuseki) example.

If you need your new builtin to run within fuseki then you would need 
some way to trigger such registration code. No doubt that's possible but 
not something I've any first hand knowledge of.

By the way, for simply getting code loaded into fuseki you don't need to 
repack the jar. Just add your new jar to the classpath and use the 
ja:loadClass function to get your class loaded when fuseki starts up. 
See last example in:

https://jena.apache.org/documentation/fuseki2/fuseki-configuration.html

Dave

On 03/06/2019 07:01, Pierre Grenon wrote:
> Hi Dave,
> 
> Executive summary:
> 
> I'm not a java coder. I did what I could to try to do this using fuseki.
> 
> I get this:
> [2019-05-31 18:47:30] Functor WARN Invoking undefined functor testBuilt in r1
> 
> I understand this may be related to RuleContext. I don't understand any 
> further.
> Details below.
> 
> With many thanks,
> Pierre
> 
> Details ---
> 
> 1. I unzipped my fuseki-server.jar
> 
> 2. I placed the code below into a ..\rulesys\testBuilt.java as
> 
> 
> package org.apache.jena.reasoner.rulesys.builtins;
> 
> 
> import org.apache.jena.graph.* ;
> import org.apache.jena.reasoner.rulesys.* ;
> 
> /**
> * Tests if the first argument is less than the second.
> */
> 
> class testBuilt extends BaseBuiltin implements Builtin {
> public String getName() {
> return "testBuilt";
> }
> 
> @Override
> public int getArgLength() {
> return 2;
> }
> 
> @Override
> public boolean bodyCall(Node[] args, int length, RuleContext context) {
> checkArgs(length, context);
> Node n1 = getArg(0, args, context);
> Node n2 = getArg(1, args, context);
> if (n1.isLiteral() && n1.isLiteral()) {
> return n1.getLiteralLexicalForm().equalsIgnore

Re: Documentation/tutorial on using dates in Jena rules with GenericRuleReasoner

2019-06-03 Thread Dave Reynolds
date and query to test 
minimal dataset with custom built-in inference using an instance of generic rule 
reasoner" ;
 fuseki:dataset:theDatasetBI ;
#:tdb_dataset_readwrite ;
 fuseki:name   "ConferenceBuiltIn" ;
 fuseki:serviceQuery   "query" , "sparql" ;
 fuseki:serviceReadGraphStore  "get" ;
 fuseki:serviceReadWriteGraphStore
 "data" ;
 fuseki:serviceUpdate  "update" ;
 fuseki:serviceUpload  "upload" .

:theDatasetBI a ja:RDFDataset ;
 ja:defaultGraph <#theModel_GRRBI> .

<#theModel_GRRBI> a ja:InfModel ;
 ja:baseModel <#theGraphBI> ;
ja:reasoner [
ja:reasonerURL 
<http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
ja:rulesFrom 

] ;
.

<#theGraphBI> rdf:type tdb2:GraphTDB ;
tdb2:dataset :theTDB2DatasetBI .

:theTDB2DatasetBI
 a  tdb2:DatasetTDB2 ;
 tdb2:location  
"C:\\dev\\apache-jena-fuseki-3.10.0\\run/databases/ConferenceBuiltIn" ;
tdb2:unionDefaultGraph true.



This is my query:
---

prefix ns: <http://test.org#>
select *
where
{?x ns:r ?z}
limit 5

This is Fuskei's log:
--

[2019-05-31 18:47:22] Server INFO  Started 2019/05/31 18:47:22 BST on port 
3030
[2019-05-31 18:47:30] Fuseki INFO  [1] POST 
http://localhost:3030/ConferenceBuiltIn/sparql
[2019-05-31 18:47:30] Fuseki INFO  [1] Query = prefix ns: 
<http://test.org#> select * where  {?x ns:r ?z} limit 5
[2019-05-31 18:47:30] FunctorWARN  Invoking undefined functor testBuilt in 
r1
[2019-05-31 18:47:30] FunctorWARN  Invoking undefined functor testBuilt in 
r1
[2019-05-31 18:47:30] FunctorWARN  Invoking undefined functor testBuilt in 
r1
[2019-05-31 18:47:30] FunctorWARN  Invoking undefined functor testBuilt in 
r1
[2019-05-31 18:47:30] FunctorWARN  Invoking undefined functor testBuilt in 
r1
[2019-05-31 18:47:30] Fuseki INFO  [1] 200 OK (78 ms)

## END OF MESSAGE

THIS E-MAIL MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION.
IF YOU ARE NOT THE INTENDED RECIPIENT (OR HAVE RECEIVED THIS E-MAIL
IN ERROR) PLEASE NOTIFY THE SENDER IMMEDIATELY AND DESTROY THIS
E-MAIL. ANY UNAUTHORISED COPYING, DISCLOSURE OR DISTRIBUTION OF THE
MATERIAL IN THIS E-MAIL IS STRICTLY FORBIDDEN.

IN ACCORDANCE WITH MIFID II RULES ON INDUCEMENTS, THE FIRM'S EMPLOYEES
MAY ATTEND CORPORATE ACCESS EVENTS (DEFINED IN THE FCA HANDBOOK AS
"THE SERVICE OF ARRANGING OR BRINGING ABOUT CONTACT BETWEEN AN INVESTMENT
MANAGER AND AN ISSUER OR POTENTIAL ISSUER"). DURING SUCH MEETINGS, THE
FIRM'S EMPLOYEES MAY ON NO ACCOUNT BE IN RECEIPT OF INSIDE INFORMATION
(AS DESCRIBED IN ARTICLE 7 OF THE MARKET ABUSE REGULATION (EU) NO 596/2014).
(https://www.handbook.fca.org.uk/handbook/glossary/G3532m.html)
COMPANIES WHO DISCLOSE INSIDE INFORMATION ARE IN BREACH OF REGULATION
AND MUST IMMEDIATELY AND CLEARLY NOTIFY ALL ATTENDEES. FOR INFORMATION
ON THE FIRM'S POLICY IN RELATION TO ITS PARTICIPATION IN MARKET SOUNDINGS,
PLEASE SEE https://www.horizon-asset.co.uk/market-soundings/.

HORIZON ASSET LLP IS AUTHORISED AND REGULATED
BY THE FINANCIAL CONDUCT AUTHORITY.


From: Dave Reynolds [mailto:dave.e.reyno...@gmail.com]
Sent: 17 May 2019 09:01
To: users@jena.apache.org
Subject: Re: Documentation/tutorial on using dates in Jena rules with 
GenericRuleReasoner

Hi Pierre,

I can't offer to hold you by the hand I'm afraid, snowed under with
work. But a minimal example might help. Here's an example of a minimal
extension builtin:

class StringEqualIgnoreCase extends BaseBuiltin implements Builtin {

public String getName() {
return "stringEqualIgnoreCase";
}

@Override
public int getArgLength() {
return 2;
}

@Override
public boolean bodyCall(Node[] args, int length, RuleContext context) {
checkArgs(length, context);
Node n1 = getArg(0, args, context);
Node n2 = getArg(1, args, context);
if (n1.isLiteral() && n1.isLiteral()) {
return n1.getLiteralLexicalForm().equalsIgnoreCase(
n2.getLiteralLexicalForm() );
} else {
return false;
}
}

}

and an example driver class for demonstrating it operating:

/**
* Rule test.
*/
public void testRuleSet2() {
String NS = "http://ont.com/";;
BuiltinRegistry.theRegistry.register( new
StringEqualIgnoreCase() );
String rules = "[r1: (?x ns:p ?pl) (?x ns:q ?ql)
stringEqualIgnoreCase(?pl, ?ql) -> (?x ns:r 'equal') ]";
Model m = ModelFactory.createDefaultModel();
Resource a = m.createResource(NS + "a");
Resource b = m.createResource(NS + "b");
Property p = m.createProperty(NS + "p");
Property q = m.createProperty(NS + "q");
m.add(a, p, "FOO");
m.add(a, q

RE: Documentation/tutorial on using dates in Jena rules with GenericRuleReasoner

2019-06-02 Thread Pierre Grenon
e tdb2:GraphTDB ;
   tdb2:dataset :theTDB2DatasetBI .

:theTDB2DatasetBI
a  tdb2:DatasetTDB2 ;
tdb2:location  
"C:\\dev\\apache-jena-fuseki-3.10.0\\run/databases/ConferenceBuiltIn" ;
tdb2:unionDefaultGraph true.



This is my query: 
---

prefix ns: <http://test.org#>
select *
where 
{?x ns:r ?z}
limit 5

This is Fuskei's log: 
--

[2019-05-31 18:47:22] Server INFO  Started 2019/05/31 18:47:22 BST on port 
3030
[2019-05-31 18:47:30] Fuseki INFO  [1] POST 
http://localhost:3030/ConferenceBuiltIn/sparql
[2019-05-31 18:47:30] Fuseki INFO  [1] Query = prefix ns: 
<http://test.org#> select * where  {?x ns:r ?z} limit 5
[2019-05-31 18:47:30] FunctorWARN  Invoking undefined functor testBuilt in 
r1
[2019-05-31 18:47:30] FunctorWARN  Invoking undefined functor testBuilt in 
r1
[2019-05-31 18:47:30] FunctorWARN  Invoking undefined functor testBuilt in 
r1
[2019-05-31 18:47:30] FunctorWARN  Invoking undefined functor testBuilt in 
r1
[2019-05-31 18:47:30] FunctorWARN  Invoking undefined functor testBuilt in 
r1
[2019-05-31 18:47:30] Fuseki INFO  [1] 200 OK (78 ms)

## END OF MESSAGE

THIS E-MAIL MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION. 
IF YOU ARE NOT THE INTENDED RECIPIENT (OR HAVE RECEIVED THIS E-MAIL 
IN ERROR) PLEASE NOTIFY THE SENDER IMMEDIATELY AND DESTROY THIS 
E-MAIL. ANY UNAUTHORISED COPYING, DISCLOSURE OR DISTRIBUTION OF THE 
MATERIAL IN THIS E-MAIL IS STRICTLY FORBIDDEN. 

IN ACCORDANCE WITH MIFID II RULES ON INDUCEMENTS, THE FIRM'S EMPLOYEES 
MAY ATTEND CORPORATE ACCESS EVENTS (DEFINED IN THE FCA HANDBOOK AS 
"THE SERVICE OF ARRANGING OR BRINGING ABOUT CONTACT BETWEEN AN INVESTMENT 
MANAGER AND AN ISSUER OR POTENTIAL ISSUER"). DURING SUCH MEETINGS, THE 
FIRM'S EMPLOYEES MAY ON NO ACCOUNT BE IN RECEIPT OF INSIDE INFORMATION 
(AS DESCRIBED IN ARTICLE 7 OF THE MARKET ABUSE REGULATION (EU) NO 596/2014). 
(https://www.handbook.fca.org.uk/handbook/glossary/G3532m.html)
COMPANIES WHO DISCLOSE INSIDE INFORMATION ARE IN BREACH OF REGULATION 
AND MUST IMMEDIATELY AND CLEARLY NOTIFY ALL ATTENDEES. FOR INFORMATION 
ON THE FIRM'S POLICY IN RELATION TO ITS PARTICIPATION IN MARKET SOUNDINGS, 
PLEASE SEE https://www.horizon-asset.co.uk/market-soundings/. 

HORIZON ASSET LLP IS AUTHORISED AND REGULATED 
BY THE FINANCIAL CONDUCT AUTHORITY.


From: Dave Reynolds [mailto:dave.e.reyno...@gmail.com] 
Sent: 17 May 2019 09:01
To: users@jena.apache.org
Subject: Re: Documentation/tutorial on using dates in Jena rules with 
GenericRuleReasoner

Hi Pierre,

I can't offer to hold you by the hand I'm afraid, snowed under with 
work. But a minimal example might help. Here's an example of a minimal 
extension builtin:

class StringEqualIgnoreCase extends BaseBuiltin implements Builtin {

public String getName() {
return "stringEqualIgnoreCase";
}

@Override
public int getArgLength() {
return 2;
}

@Override
public boolean bodyCall(Node[] args, int length, RuleContext context) {
checkArgs(length, context);
Node n1 = getArg(0, args, context);
Node n2 = getArg(1, args, context);
if (n1.isLiteral() && n1.isLiteral()) {
return n1.getLiteralLexicalForm().equalsIgnoreCase( 
n2.getLiteralLexicalForm() );
} else {
return false;
}
}

}

and an example driver class for demonstrating it operating:

/**
* Rule test.
*/
public void testRuleSet2() {
String NS = "http://ont.com/";;
BuiltinRegistry.theRegistry.register( new 
StringEqualIgnoreCase() );
String rules = "[r1: (?x ns:p ?pl) (?x ns:q ?ql) 
stringEqualIgnoreCase(?pl, ?ql) -> (?x ns:r 'equal') ]";
Model m = ModelFactory.createDefaultModel();
Resource a = m.createResource(NS + "a");
Resource b = m.createResource(NS + "b");
Property p = m.createProperty(NS + "p");
Property q = m.createProperty(NS + "q");
m.add(a, p, "FOO");
m.add(a, q, "foo");
m.add(b, p, "FOO");
m.add(b, q, "foobar");
GenericRuleReasoner reasoner = new GenericRuleReasoner(Rule
.parseRules(rules));
InfModel infModel = ModelFactory.createInfModel(reasoner, m);
infModel.write(System.out, "Turtle");
}

These are cut/paste from some very ancient examples but hopefully should 
work, if not let us know I can see about assembling it into a self 
contained working example.

As it says in the documentation, for examples of how to write particular 
sorts of builtin then the best place is to look is the source code for 
the current builtins.

Dave

On 17/05/2019 07:53, Pierre Grenon wrote:
> Hi
> 
> Thanks again.
> 
> Hear you.
> 
> I think this is becoming a bit too meta perhaps. Maybe there’s a couple of 
> ways to go forward.
> 
> 
> a. Anybody is a taker to hold me by the hand and use this thread to come up 
> with a complete cycle for making a new built in and adding i

RE: Documentation/tutorial on using dates in Jena rules with GenericRuleReasoner

2019-05-23 Thread Pierre Grenon
Further to the below. 

I am now pasting a config file in which I use both the Generic Rule Reasoner 
for the rule and RDFS for class subsumption.

THIS E-MAIL MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION. 
IF YOU ARE NOT THE INTENDED RECIPIENT (OR HAVE RECEIVED THIS E-MAIL 
IN ERROR) PLEASE NOTIFY THE SENDER IMMEDIATELY AND DESTROY THIS 
E-MAIL. ANY UNAUTHORISED COPYING, DISCLOSURE OR DISTRIBUTION OF THE 
MATERIAL IN THIS E-MAIL IS STRICTLY FORBIDDEN. 

IN ACCORDANCE WITH MIFID II RULES ON INDUCEMENTS, THE FIRM'S EMPLOYEES 
MAY ATTEND CORPORATE ACCESS EVENTS (DEFINED IN THE FCA HANDBOOK AS 
"THE SERVICE OF ARRANGING OR BRINGING ABOUT CONTACT BETWEEN AN INVESTMENT 
MANAGER AND AN ISSUER OR POTENTIAL ISSUER"). DURING SUCH MEETINGS, THE 
FIRM'S EMPLOYEES MAY ON NO ACCOUNT BE IN RECEIPT OF INSIDE INFORMATION 
(AS DESCRIBED IN ARTICLE 7 OF THE MARKET ABUSE REGULATION (EU) NO 596/2014). 
(https://www.handbook.fca.org.uk/handbook/glossary/G3532m.html)
COMPANIES WHO DISCLOSE INSIDE INFORMATION ARE IN BREACH OF REGULATION 
AND MUST IMMEDIATELY AND CLEARLY NOTIFY ALL ATTENDEES. FOR INFORMATION 
ON THE FIRM'S POLICY IN RELATION TO ITS PARTICIPATION IN MARKET SOUNDINGS, 
PLEASE SEE https://www.horizon-asset.co.uk/market-soundings/. 

HORIZON ASSET LLP IS AUTHORISED AND REGULATED 
BY THE FINANCIAL CONDUCT AUTHORITY.


CAVEAT: This may appear trivial yet it was not straightforward to me how this 
works so any comment on this type of config is obviously most welcome 
independently of the dates aspect. 

On my end this concludes this part of the thread. I will use this config and 
the data as an extensible basis to figure out new built ins, although I have no 
clue when that might be -- all current conferences might have their deadlines 
passed by the time I get to this...

With many thanks and kind regards, 
Pierre 

For reference: 

/Conference1 allows deriving the expected facts from the rules but did not 
support RDFS 
/Conference2 allows returning bindings for the following query:
select * where 
{?x a <http://test.org#OrganisedEvent> . ?x <http://test.org#hasStatus> ?e} 


### START CONFIG 2: Conference_GRR_RDFS.ttl ###

@prefix :  <http://base/#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix tdb2:  <http://jena.apache.org/2016/tdb#> .
@prefix ja:<http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix fuseki: <http://jena.apache.org/fuseki#> .

:theService a   fuseki:Service ;
rdfs:label"Service with update and query to test 
minimal dataset with inference using an instance of generic rule reasoner and 
RDFSExptRuleReasoner" ;
fuseki:dataset:theDataset ;
#:tdb_dataset_readwrite ;
fuseki:name   "Conference2" ;
fuseki:serviceQuery   "query" , "sparql" ;
fuseki:serviceReadGraphStore  "get" ;
fuseki:serviceReadWriteGraphStore
"data" ;
fuseki:serviceUpdate  "update" ;
fuseki:serviceUpload  "upload" .

:theDataset a ja:RDFDataset ; 
ja:defaultGraph <#theUnionModel>
.

<#theUnionModel> a ja:UnionModel ;
ja:rootModel <#theRootModel> ;
ja:subModel <#theModel_GRR> , <#theModel_RDFS> .

<#theRootModel> a ja:Model ;
ja:baseModel <#theGraph> ;
.


<#theModel_GRR> a ja:InfModel ;
ja:baseModel <#theGraph> ;
ja:reasoner [
ja:reasonerURL 
<http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
ja:rulesFrom 
 
] ;
.

<#theModel_RDFS> a ja:InfModel ;
ja:baseModel <#theGraph> ;
ja:reasoner [
ja:reasonerURL <http://jena.hpl.hp.com/2003/RDFSExptRuleReasoner> 
] ;
.

<#theGraph> rdf:type tdb2:GraphTDB ;
   tdb2:dataset :theTDB2Dataset .

:theTDB2Dataset
a  tdb2:DatasetTDB2 ;
tdb2:location  
"C:\\dev\\apache-jena-fuseki-3.10.0\\run/databases/Conference1" ;
tdb2:unionDefaultGraph true.

### END CONFIG 2: Conference_GRR_RDFS.ttl ###   


> -Original Message-
> From: Pierre Grenon
> Sent: 23 May 2019 06:23
> To: 'users@jena.apache.org'
> Subject: RE: Documentation/tutorial on using dates in Jena rules with
> GenericRuleReasoner
> 
> Apologies for repost -- it *feels* like attaching stuff to emails is not the 
> right
> thing to do. So, for all it's worth, as I would find it useful myself, files 
> copied
> below.
> 
> Many thanks,
> Pierre
> 
> 
> 
> - Conference_GRR_onerule.ttl --- fuseki config with TDB2 and ge

RE: Documentation/tutorial on using dates in Jena rules with GenericRuleReasoner

2019-05-22 Thread Pierre Grenon
Apologies for repost -- it *feels* like attaching stuff to emails is not the 
right thing to do. So, for all it's worth, as I would find it useful myself, 
files copied below. 

Many thanks, 
Pierre



- Conference_GRR_onerule.ttl --- fuseki config with TDB2 and generic rule 
reasoner
### START CONFIG ###

@prefix :  <http://base/#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix tdb2:  <http://jena.apache.org/2016/tdb#> .
@prefix ja:<http://jena.hpl.hp.com/2005/11/Assembler#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .
@prefix fuseki: <http://jena.apache.org/fuseki#> .

:theService a   fuseki:Service ;
rdfs:label"Service with update and query to test 
minimal dataset with inference using an instance of generic rule reasoner" ;
fuseki:dataset:theDataset ;
#:tdb_dataset_readwrite ;
fuseki:name   "Conference1" ;
fuseki:serviceQuery   "query" , "sparql" ;
fuseki:serviceReadGraphStore  "get" ;
fuseki:serviceReadWriteGraphStore
"data" ;
fuseki:serviceUpdate  "update" ;
fuseki:serviceUpload  "upload" .

:theDataset a ja:RDFDataset ; 
ja:defaultGraph <#theModel_GRR> .

<#theModel_GRR> a ja:InfModel ;
ja:baseModel <#theGraph> ;
ja:reasoner [
ja:reasonerURL 
<http://jena.hpl.hp.com/2003/GenericRuleReasoner> ;
ja:rulesFrom 
 
] ;
.

<#theGraph> rdf:type tdb2:GraphTDB ;
   tdb2:dataset :theTDB2Dataset .

:theTDB2Dataset
a  tdb2:DatasetTDB2 ;
tdb2:location  
"C:\\dev\\apache-jena-fuseki-3.10.0\\run/databases/Conference1" ;
tdb2:unionDefaultGraph true.

### END CONFIG ###

- conference1.ttl 
### START DATA ###

@prefix : <http://test.org#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .

### OE
<http://test.org#OrganisedEvent> rdf:type owl:Class ;
rdfs:label "organised event" .

<http://test.org#Conference> rdf:type owl:Class ;
rdfs:subClassOf <http://test.org#OrganisedEvent> ;
rdfs:label "conference" .

<http://test.org#Workshop> rdf:type owl:Class ; 
rdfs:subClassOf <http://test.org#OrganisedEvent> ;
rdfs:label "workshop" .

<http://test.org#hasDeadline> rdf:type owl:DatatypeProperty ;
rdfs:domain <http://test.org#OrganisedEvent> ;
rdfs:range xsd:dateTime ;
rdfs:label "deadline passed" .

<http://test.org#Status> rdf:type owl:Class ; 
rdfs:label "Status" .

<http://test.org#hasStatus> 
rdf:type owl:ObjectProperty ;
rdfs:domain <http://test.org#OrganisedEvent> ;
rdfs:range <http://test.org#Status> ;
rdfs:label "has status" .

<http://test.org#Status_DeadlinePassed> 
rdf:type owl:NamedIndividual , <http://test.org#Status> ;
rdfs:label "deadline passed" .

<http://test.org#Status_DeadlineActive> 
rdf:type owl:NamedIndividual , <http://test.org#Status> ;
rdfs:label "deadline active" .


### KB
<http://test.org#Conference1> rdf:type owl:NamedIndividual , 
<http://test.org#Conference> ;
<http://test.org#hasDeadline>"2019-01-01T00:00:00Z"^^xsd:dateTime ;
rdfs:label "1st Intl Conf of the Penguin Appreciation Society" .

<http://test.org#Conference2> rdf:type owl:NamedIndividual , 
<http://test.org#Conference> ;
<http://test.org#hasDeadline>"3019-01-01T00:00:00Z"^^xsd:dateTime ;
rdfs:label "101st Conf of the Penguin Appreciation Society" .

<http://test.org#Workshop1> rdf:type owl:NamedIndividual , 
<http://test.org#Workshop> ;
<http://test.org#hasDeadline>"2018-07-01T00:00:00Z"^^xsd:dateTime ;
rdfs:label "How to walk like a penguin" .

<http://test.org#Workshop2> rdf:type owl:NamedIndividual , 
<http://test.org#Workshop> ;
<http://test.org#hasDeadline>"2030-07-01T00:00:00Z"^^xsd:dateTime ;
rdfs:label "Do penguins walk?" .

### END DATA ###

- conference1.rules 
### START RULE###
@prefix ns: <http://test.org#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#&

RE: Documentation/tutorial on using dates in Jena rules with GenericRuleReasoner

2019-05-22 Thread Pierre Grenon
Thank you, Dave – I am yet to struggle with this. Hope to be in a position to 
follow up

Best
Pierre

THIS E-MAIL MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION. 
IF YOU ARE NOT THE INTENDED RECIPIENT (OR HAVE RECEIVED THIS E-MAIL 
IN ERROR) PLEASE NOTIFY THE SENDER IMMEDIATELY AND DESTROY THIS 
E-MAIL. ANY UNAUTHORISED COPYING, DISCLOSURE OR DISTRIBUTION OF THE 
MATERIAL IN THIS E-MAIL IS STRICTLY FORBIDDEN. 

IN ACCORDANCE WITH MIFID II RULES ON INDUCEMENTS, THE FIRM'S EMPLOYEES 
MAY ATTEND CORPORATE ACCESS EVENTS (DEFINED IN THE FCA HANDBOOK AS 
"THE SERVICE OF ARRANGING OR BRINGING ABOUT CONTACT BETWEEN AN INVESTMENT 
MANAGER AND AN ISSUER OR POTENTIAL ISSUER"). DURING SUCH MEETINGS, THE 
FIRM'S EMPLOYEES MAY ON NO ACCOUNT BE IN RECEIPT OF INSIDE INFORMATION 
(AS DESCRIBED IN ARTICLE 7 OF THE MARKET ABUSE REGULATION (EU) NO 596/2014). 
(https://www.handbook.fca.org.uk/handbook/glossary/G3532m.html)
COMPANIES WHO DISCLOSE INSIDE INFORMATION ARE IN BREACH OF REGULATION 
AND MUST IMMEDIATELY AND CLEARLY NOTIFY ALL ATTENDEES. FOR INFORMATION 
ON THE FIRM'S POLICY IN RELATION TO ITS PARTICIPATION IN MARKET SOUNDINGS, 
PLEASE SEE https://www.horizon-asset.co.uk/market-soundings/. 

HORIZON ASSET LLP IS AUTHORISED AND REGULATED 
BY THE FINANCIAL CONDUCT AUTHORITY.


From: Dave Reynolds [mailto:dave.e.reyno...@gmail.com]
Sent: 17 May 2019 09:01
To: users@jena.apache.org
Subject: Re: Documentation/tutorial on using dates in Jena rules with 
GenericRuleReasoner

Hi Pierre,

I can't offer to hold you by the hand I'm afraid, snowed under with
work. But a minimal example might help. Here's an example of a minimal
extension builtin:

class StringEqualIgnoreCase extends BaseBuiltin implements Builtin {

public String getName() {
return "stringEqualIgnoreCase";
}

@Override
public int getArgLength() {
return 2;
}

@Override
public boolean bodyCall(Node[] args, int length, RuleContext context) {
checkArgs(length, context);
Node n1 = getArg(0, args, context);
Node n2 = getArg(1, args, context);
if (n1.isLiteral() && n1.isLiteral()) {
return n1.getLiteralLexicalForm().equalsIgnoreCase(
n2.getLiteralLexicalForm() );
} else {
return false;
}
}

}

and an example driver class for demonstrating it operating:

/**
* Rule test.
*/
public void testRuleSet2() {
String NS = "http://ont.com/<http://ont.com/>";
BuiltinRegistry.theRegistry.register( new
StringEqualIgnoreCase() );
String rules = "[r1: (?x ns:p ?pl) (?x ns:q ?ql)
stringEqualIgnoreCase(?pl, ?ql) -> (?x ns:r 'equal') ]";
Model m = ModelFactory.createDefaultModel();
Resource a = m.createResource(NS + "a");
Resource b = m.createResource(NS + "b");
Property p = m.createProperty(NS + "p");
Property q = m.createProperty(NS + "q");
m.add(a, p, "FOO");
m.add(a, q, "foo");
m.add(b, p, "FOO");
m.add(b, q, "foobar");
GenericRuleReasoner reasoner = new GenericRuleReasoner(Rule
.parseRules(rules));
InfModel infModel = ModelFactory.createInfModel(reasoner, m);
infModel.write(System.out, "Turtle");
}

These are cut/paste from some very ancient examples but hopefully should
work, if not let us know I can see about assembling it into a self
contained working example.

As it says in the documentation, for examples of how to write particular
sorts of builtin then the best place is to look is the source code for
the current builtins.

Dave

On 17/05/2019 07:53, Pierre Grenon wrote:
> Hi
>
> Thanks again.
>
> Hear you.
>
> I think this is becoming a bit too meta perhaps. Maybe there’s a couple of 
> ways to go forward.
>
>
> a. Anybody is a taker to hold me by the hand and use this thread to come up 
> with a complete cycle for making a new built in and adding it to my fuseki? 
> If somebody has the time to do this---and I’m happy that it takes what it 
> takes, I can’t on my end make it a high priority--, we could reuse the thread 
> for the purpose of a detailed how-to for noobs like me.
>
> b. I think I actually tried the rule below and I didn’t get any inference 
> result. Don’t know if it’s my config, my rule or my data. I could start a. by 
> trying to provide a dataset and config file as well. Again, anybody willing 
> to hold my hand?
>
> Give a shout.
>
> Thanks,
> Pierre
>
> From: Lorenz B. [mailto:buehm...@informatik.uni-leipzig.de]
> Sent: 17 May 2019 07:24
> To: users@jena.apache.org
> Subject: Re: Documentation/tutorial on using dates in Jena rules with 
> GenericRuleReasoner
>
> Hi,
>
>> Hi Lorenz,
>>
>> Thank you for your answer.
>>
>> Quick follow up.
>>
>> I think the issue for me is the documentation of the built-ins is too 
>> abstract or relies on understanding the source code. So I suppose, 
>> documentation / tuto

RE: Documentation/tutorial on using dates in Jena rules with GenericRuleReasoner

2019-05-22 Thread Pierre Grenon
Hi – yes, it works for me using fuseki as well. Apologies, I think my config 
file was bad or the data somehow.

For reference, similar to your test:


-Conference_GRR_onerule.ttl --- fuseki config with TDB2 and generic 
rule reasoner

-conference1.ttl --- small test set, with more than minimal data

-conference1.rules --- single (same) rule

Query: select * where {?x <http://test.org#hasStatus> ?z}


From: Lorenz B. [mailto:buehm...@informatik.uni-leipzig.de]
Sent: 18 May 2019 19:12
To: users@jena.apache.org
Subject: Re: Documentation/tutorial on using dates in Jena rules with 
GenericRuleReasoner


> b. I think I actually tried the rule below and I didn’t get any inference 
> result. Don’t know if it’s my config, my rule or my data. I could start a. by 
> trying to provide a dataset and config file as well. Again, anybody willing 
> to hold my hand?

Works for me as expected:

|Model m = ModelFactory.createDefaultModel();||
||String s = "@prefix ns: <http://test.org/<http://test.org/>> .\n" +||
||   "@prefix xsd: 
<http://www.w3.org/2001/XMLSchema#<http://www.w3.org/2001/XMLSchema#>> .\n" +||
||   " ns:hasDeadline
\"2002-05-30T09:00:00\"^^xsd:dateTime .";
||m.read(new StringReader(s), null, "Turtle");||
||
||String rule =||
||" [ruleMissedDeadline2: (?conference
<http://test.org/hasDeadline<http://test.org/hasDeadline>> ?date) now(?now) 
greaterThan(?now, ?date)
" +||
||"-> (?conference 
<http://test.org/status<http://test.org/status>>
<http://test.org/DeadlinePassed<http://test.org/DeadlinePassed>>)]";||
||
||List rules = Rule.parseRules(rule);||
||Reasoner reasoner = new GenericRuleReasoner(rules);||
||Model infModel = ModelFactory.createInfModel(reasoner, m);||
||infModel.write(System.out, "N-Triples");|



> Give a shout.
>
> Thanks,
> Pierre
>
> From: Lorenz B. [mailto:buehm...@informatik.uni-leipzig.de]
> Sent: 17 May 2019 07:24
> To: users@jena.apache.org
> Subject: Re: Documentation/tutorial on using dates in Jena rules with 
> GenericRuleReasoner
>
> Hi,
>
>> Hi Lorenz,
>>
>> Thank you for your answer.
>>
>> Quick follow up.
>>
>> I think the issue for me is the documentation of the built-ins is too 
>> abstract or relies on understanding the source code. So I suppose, 
>> documentation / tutorial seems somewhat superfluous when you can do that – 
>> only I can’t understand what’s there and the source at the moment.
> I can see that it might be too abstract for people coming from different
> areas, sure. But, the question is who is able to provide such a tutorial
> and also who has the time. It's always a trade-off in Open Source
> projects like Jena - I guess most of the devs or other project related
> people here are not getting payed, and clearly such a tutorial for most
> if not all of the built-ins definitely needs some effort. Ideally, the
> community could take over those things, but looks like nobody ever wrote
> blog posts or tutorials about the Jena rule system and its built-ins.
>>
>>
>> 1. Yes, I seem to understand difference is a no go but I was wondering if 
>> there might be some work around coercing the dateTime to something else. I’m 
>> not sure I understood that very well but it looks like I can’t use functions 
>> in arguments of built-ins (so no xsd:year(?date) or whatever).
> I don't think you can use functions or expressions from the SPARQL
> engine resp. its XPath constructors. Both are totally different
> implementations I guess - but again, I'm not a developer, so I can't
> make a valid statement, except for looking into the code and the docs.
> From my point of view, only the mentioned built-ins from the docs are
> valid so far.
>>
>>
>> But then, on greaterThan, something should be workable if I have 
>> xsd:dateTime, no?
>>
>> What’s wrong with :
>>
>>
>>
>> [ruleMissedDeadline2:
>>
>> (?conference ns:hasDeadline ?date)
>>
>> now(?now)
>>
>> greaterThan(?now, ?date)
>>
>> ->
>>
>> (?conference ns:status ns:DeadlinePassed)
>>
>> ]
> Well I was clearly thinking too complicated, so yes, your rule should
> work given that the docs say
>
>> lessThan(?x, ?y), greaterThan(?x, ?y)
>> le(?x, ?y), ge(?x, ?y)
>>
>> Test if x is <, >, <= or >= y. Only passes if both x and y are numbers
>> or time instants (can be integer or floating point or XSDDateTime).
> I was more thinking about things like inferring the age of a person
&g

Re: Documentation/tutorial on using dates in Jena rules with GenericRuleReasoner

2019-05-18 Thread Lorenz B.

> b.  I think I actually tried the rule below and I didn’t get any 
> inference result. Don’t know if it’s my config, my rule or my data. I could 
> start a. by trying to provide a dataset and config file as well. Again, 
> anybody willing to hold my hand?

Works for me as expected:

|    Model m = ModelFactory.createDefaultModel();||
||    String s = "@prefix ns: <http://test.org/> .\n" +||
||   "@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .\n" +||
||   " ns:hasDeadline
\"2002-05-30T09:00:00\"^^xsd:dateTime .";
||    m.read(new StringReader(s), null, "Turtle");||
||
||    String rule =||
||    " [ruleMissedDeadline2: (?conference
<http://test.org/hasDeadline> ?date) now(?now) greaterThan(?now, ?date)
" +||
||    "-> (?conference <http://test.org/status>
<http://test.org/DeadlinePassed>)]";||
||
||    List rules = Rule.parseRules(rule);||
||    Reasoner reasoner = new GenericRuleReasoner(rules);||
||    Model infModel = ModelFactory.createInfModel(reasoner, m);||
||    infModel.write(System.out, "N-Triples");|



> Give a shout.
>
> Thanks,
> Pierre
>
> From: Lorenz B. [mailto:buehm...@informatik.uni-leipzig.de]
> Sent: 17 May 2019 07:24
> To: users@jena.apache.org
> Subject: Re: Documentation/tutorial on using dates in Jena rules with 
> GenericRuleReasoner
>
> Hi,
>
>> Hi Lorenz,
>>
>> Thank you for your answer.
>>
>> Quick follow up.
>>
>> I think the issue for me is the documentation of the built-ins is too 
>> abstract or relies on understanding the source code. So I suppose, 
>> documentation / tutorial seems somewhat superfluous when you can do that – 
>> only I can’t understand what’s there and the source at the moment.
> I can see that it might be too abstract for people coming from different
> areas, sure. But, the question is who is able to provide such a tutorial
> and also who has the time. It's always a trade-off in Open Source
> projects like Jena - I guess most of the devs or other project related
> people here are not getting payed, and clearly such a tutorial for most
> if not all of the built-ins definitely needs some effort. Ideally, the
> community could take over those things, but looks like nobody ever wrote
> blog posts or tutorials about the Jena rule system and its built-ins.
>>
>>
>> 1. Yes, I seem to understand difference is a no go but I was wondering if 
>> there might be some work around coercing the dateTime to something else. I’m 
>> not sure I understood that very well but it looks like I can’t use functions 
>> in arguments of built-ins (so no xsd:year(?date) or whatever).
> I don't think you can use functions or expressions from the SPARQL
> engine resp. its XPath constructors. Both are totally different
> implementations I guess - but again, I'm not a developer, so I can't
> make a valid statement, except for looking into the code and the docs.
> From my point of view, only the mentioned built-ins from the docs are
> valid so far.
>>
>>
>> But then, on greaterThan, something should be workable if I have 
>> xsd:dateTime, no?
>>
>> What’s wrong with :
>>
>>
>>
>> [ruleMissedDeadline2:
>>
>> (?conference ns:hasDeadline ?date)
>>
>> now(?now)
>>
>> greaterThan(?now, ?date)
>>
>> ->
>>
>> (?conference ns:status ns:DeadlinePassed)
>>
>> ]
> Well I was clearly thinking too complicated, so yes, your rule should
> work given that the docs say
>
>> lessThan(?x, ?y), greaterThan(?x, ?y)
>> le(?x, ?y), ge(?x, ?y)
>>
>> Test if x is <, >, <= or >= y. Only passes if both x and y are numbers
>> or time instants (can be integer or floating point or XSDDateTime).
> I was more thinking about things like inferring the age of a person
> isn't possible right now, but would clearly be some nice to have feature
> such that you could have it as implicit fact in your KB without the need
> to change the asserted data every year.
>
>> 2. When you say extend the rule system, you mean adding a class using as a 
>> starting point something is in ..rulesys.builtins and adapting it and then 
>> rebuild all the jars. I’m using Fuseki, so I’d have to rebuild that too, 
>> yeah? Aside from the fact I’m not coding in java, this isn’t the easiest 
>> path for me at the moment.
> That's also something I can't answer properly. I mean, yes, you can
> create custom built-ins and register those or maybe create an overriding
> registry [1] ? But not sure, it looks like at least the 

Re: Documentation/tutorial on using dates in Jena rules with GenericRuleReasoner

2019-05-17 Thread Dave Reynolds

Hi Pierre,

I can't offer to hold you by the hand I'm afraid, snowed under with 
work. But a minimal example might help. Here's an example of a minimal 
extension builtin:


class StringEqualIgnoreCase extends BaseBuiltin implements Builtin {

public String getName() {
return "stringEqualIgnoreCase";
}

@Override
public int getArgLength() {
return 2;
}

@Override
public boolean bodyCall(Node[] args, int length, RuleContext context) {
checkArgs(length, context);
Node n1 = getArg(0, args, context);
Node n2 = getArg(1, args, context);
if (n1.isLiteral() && n1.isLiteral()) {
return n1.getLiteralLexicalForm().equalsIgnoreCase( 
n2.getLiteralLexicalForm() );

} else {
return false;
}
}

}

and an example driver class for demonstrating it operating:

/**
 * Rule test.
 */
public void testRuleSet2() {
String NS = "http://ont.com/";;
BuiltinRegistry.theRegistry.register( new 
StringEqualIgnoreCase() );
String rules = "[r1: (?x ns:p ?pl) (?x ns:q ?ql) 
stringEqualIgnoreCase(?pl, ?ql) -> (?x ns:r 'equal') ]";

Model m = ModelFactory.createDefaultModel();
Resource a = m.createResource(NS + "a");
Resource b = m.createResource(NS + "b");
Property p = m.createProperty(NS + "p");
Property q = m.createProperty(NS + "q");
m.add(a, p, "FOO");
m.add(a, q, "foo");
m.add(b, p, "FOO");
m.add(b, q, "foobar");
GenericRuleReasoner reasoner = new GenericRuleReasoner(Rule
.parseRules(rules));
InfModel infModel = ModelFactory.createInfModel(reasoner, m);
infModel.write(System.out, "Turtle");
}

These are cut/paste from some very ancient examples but hopefully should 
work, if not let us know I can see about assembling it into a self 
contained working example.


As it says in the documentation, for examples of how to write particular 
sorts of builtin then the best place is to look is the source code for 
the current builtins.


Dave

On 17/05/2019 07:53, Pierre Grenon wrote:

Hi

Thanks again.

Hear you.

I think this is becoming a bit too meta perhaps. Maybe there’s a couple of ways 
to go forward.


a.  Anybody is a taker to hold me by the hand and use this thread to come 
up with a complete cycle for making a new built in and adding it to my fuseki? 
If somebody has the time to do this---and I’m happy that it takes what it 
takes, I can’t on my end make it a high priority--, we could reuse the thread 
for the purpose of a detailed how-to for noobs like me.

b.  I think I actually tried the rule below and I didn’t get any inference 
result. Don’t know if it’s my config, my rule or my data. I could start a. by 
trying to provide a dataset and config file as well. Again, anybody willing to 
hold my hand?

Give a shout.

Thanks,
Pierre

From: Lorenz B. [mailto:buehm...@informatik.uni-leipzig.de]
Sent: 17 May 2019 07:24
To: users@jena.apache.org
Subject: Re: Documentation/tutorial on using dates in Jena rules with 
GenericRuleReasoner

Hi,


Hi Lorenz,

Thank you for your answer.

Quick follow up.

I think the issue for me is the documentation of the built-ins is too abstract 
or relies on understanding the source code. So I suppose, documentation / 
tutorial seems somewhat superfluous when you can do that – only I can’t 
understand what’s there and the source at the moment.

I can see that it might be too abstract for people coming from different
areas, sure. But, the question is who is able to provide such a tutorial
and also who has the time. It's always a trade-off in Open Source
projects like Jena - I guess most of the devs or other project related
people here are not getting payed, and clearly such a tutorial for most
if not all of the built-ins definitely needs some effort. Ideally, the
community could take over those things, but looks like nobody ever wrote
blog posts or tutorials about the Jena rule system and its built-ins.




1. Yes, I seem to understand difference is a no go but I was wondering if there 
might be some work around coercing the dateTime to something else. I’m not sure 
I understood that very well but it looks like I can’t use functions in 
arguments of built-ins (so no xsd:year(?date) or whatever).

I don't think you can use functions or expressions from the SPARQL
engine resp. its XPath constructors. Both are totally different
implementations I guess - but again, I'm not a developer, so I can't
make a valid statement, except for looking into the code and the docs.
 From my point of view, only the mentioned built-ins from the docs are
valid so far.




But then, on greaterThan, something should be workable if I have xsd:dateTime, 
no?

What’s wrong

RE: Documentation/tutorial on using dates in Jena rules with GenericRuleReasoner

2019-05-17 Thread Pierre Grenon
Hi

Thanks again.

Hear you.

I think this is becoming a bit too meta perhaps. Maybe there’s a couple of ways 
to go forward.


a.  Anybody is a taker to hold me by the hand and use this thread to come 
up with a complete cycle for making a new built in and adding it to my fuseki? 
If somebody has the time to do this---and I’m happy that it takes what it 
takes, I can’t on my end make it a high priority--, we could reuse the thread 
for the purpose of a detailed how-to for noobs like me.

b.  I think I actually tried the rule below and I didn’t get any inference 
result. Don’t know if it’s my config, my rule or my data. I could start a. by 
trying to provide a dataset and config file as well. Again, anybody willing to 
hold my hand?

Give a shout.

Thanks,
Pierre

From: Lorenz B. [mailto:buehm...@informatik.uni-leipzig.de]
Sent: 17 May 2019 07:24
To: users@jena.apache.org
Subject: Re: Documentation/tutorial on using dates in Jena rules with 
GenericRuleReasoner

Hi,

> Hi Lorenz,
>
> Thank you for your answer.
>
> Quick follow up.
>
> I think the issue for me is the documentation of the built-ins is too 
> abstract or relies on understanding the source code. So I suppose, 
> documentation / tutorial seems somewhat superfluous when you can do that – 
> only I can’t understand what’s there and the source at the moment.
I can see that it might be too abstract for people coming from different
areas, sure. But, the question is who is able to provide such a tutorial
and also who has the time. It's always a trade-off in Open Source
projects like Jena - I guess most of the devs or other project related
people here are not getting payed, and clearly such a tutorial for most
if not all of the built-ins definitely needs some effort. Ideally, the
community could take over those things, but looks like nobody ever wrote
blog posts or tutorials about the Jena rule system and its built-ins.
>
>
>
> 1. Yes, I seem to understand difference is a no go but I was wondering if 
> there might be some work around coercing the dateTime to something else. I’m 
> not sure I understood that very well but it looks like I can’t use functions 
> in arguments of built-ins (so no xsd:year(?date) or whatever).
I don't think you can use functions or expressions from the SPARQL
engine resp. its XPath constructors. Both are totally different
implementations I guess - but again, I'm not a developer, so I can't
make a valid statement, except for looking into the code and the docs.
From my point of view, only the mentioned built-ins from the docs are
valid so far.
>
>
>
> But then, on greaterThan, something should be workable if I have 
> xsd:dateTime, no?
>
> What’s wrong with :
>
>
>
> [ruleMissedDeadline2:
>
> (?conference ns:hasDeadline ?date)
>
> now(?now)
>
> greaterThan(?now, ?date)
>
> ->
>
> (?conference ns:status ns:DeadlinePassed)
>
> ]

Well I was clearly thinking too complicated, so yes, your rule should
work given that the docs say

> lessThan(?x, ?y), greaterThan(?x, ?y)
> le(?x, ?y), ge(?x, ?y)
>
> Test if x is <, >, <= or >= y. Only passes if both x and y are numbers
> or time instants (can be integer or floating point or XSDDateTime).
I was more thinking about things like inferring the age of a person
isn't possible right now, but would clearly be some nice to have feature
such that you could have it as implicit fact in your KB without the need
to change the asserted data every year.

>
> 2. When you say extend the rule system, you mean adding a class using as a 
> starting point something is in ..rulesys.builtins and adapting it and then 
> rebuild all the jars. I’m using Fuseki, so I’d have to rebuild that too, 
> yeah? Aside from the fact I’m not coding in java, this isn’t the easiest path 
> for me at the moment.

That's also something I can't answer properly. I mean, yes, you can
create custom built-ins and register those or maybe create an overriding
registry [1] ? But not sure, it looks like at least the overriding
registry would have to be used by the rule parser, so I don't know how
you would have to combine it with Fuseki. And in the end, yes, you have
to repackage Fuseki I think as long as you modify the existing
BuiltinRegistry.

Maybe there is also some other kind of plugin system here, but that can
only be answered by Andy, Dave, Adam, etc.


[1] 
https://issues.apache.org/jira/browse/JENA-1204<https://issues.apache.org/jira/browse/JENA-1204>

>
> Many thanks,
> Pierre
>
>
> From: Lorenz B. [mailto:buehm...@informatik.uni-leipzig.de]
> Sent: 16 May 2019 08:33
> To: users@jena.apache.org
> Subject: Re: Documentation/tutorial on using dates in Jena rules with 
> GenericRuleReasoner
>
> I'm not aware of any tutorial, but afaik you can't do what you d

Re: Documentation/tutorial on using dates in Jena rules with GenericRuleReasoner

2019-05-16 Thread Lorenz B.
Hi,

> Hi Lorenz,
>
> Thank you for your answer.
>
> Quick follow up.
>
> I think the issue for me is the documentation of the built-ins is too 
> abstract or relies on understanding the source code. So I suppose, 
> documentation / tutorial seems somewhat superfluous when you can do that – 
> only I can’t understand what’s there and the source at the moment.
I can see that it might be too abstract for people coming from different
areas, sure. But, the question is who is able to provide such a tutorial
and also who has the time. It's always a trade-off in Open Source
projects like Jena - I guess most of the devs or other project related
people here are not getting payed, and clearly such a tutorial for most
if not all of the built-ins definitely needs some effort. Ideally, the
community could take over those things, but looks like nobody ever wrote
blog posts or tutorials about the Jena rule system and its built-ins.
>
>
>
> 1.  Yes, I seem to understand difference is a no go but I was wondering 
> if there might be some work around coercing the dateTime to something else. 
> I’m not sure I understood that very well but it looks like I can’t use 
> functions in arguments of built-ins (so no xsd:year(?date) or whatever).
I don't think you can use functions or expressions from the SPARQL
engine resp. its XPath constructors. Both are totally different
implementations I guess - but again, I'm not a developer, so I can't
make a valid statement, except for looking into the code and the docs.
From my point of view, only the mentioned built-ins from the docs are
valid so far.
>
>
>
> But then, on greaterThan, something should be workable if I have 
> xsd:dateTime, no?
>
> What’s wrong with :
>
>
>
> [ruleMissedDeadline2:
>
> (?conference ns:hasDeadline ?date)
>
> now(?now)
>
> greaterThan(?now, ?date)
>
> ->
>
> (?conference ns:status ns:DeadlinePassed)
>
> ]

Well I was clearly thinking too complicated, so yes, your rule should
work given that the docs say

> lessThan(?x, ?y), greaterThan(?x, ?y)
> le(?x, ?y), ge(?x, ?y)
>
> Test if x is <, >, <= or >= y. Only passes if both x and y are numbers
> or time instants (can be integer or floating point or XSDDateTime).
I was more thinking about things like inferring the age of a person
isn't possible right now, but would clearly be some nice to have feature
such that you could have it as implicit fact in your KB without the need
to change the asserted data every year.

>
> 2. When you say extend the rule system, you mean adding a class using as a 
> starting point something is in ..rulesys.builtins and adapting it and then 
> rebuild all the jars. I’m using Fuseki, so I’d have to rebuild that too, 
> yeah? Aside from the fact I’m not coding in java, this isn’t the easiest path 
> for me at the moment.

That's also something I can't answer properly. I mean, yes, you can
create custom built-ins and register those or maybe create an overriding
registry [1] ? But not sure, it looks like at least the overriding
registry would have to be used by the rule parser, so I don't know how
you would have to combine it with Fuseki. And in the end, yes, you have
to repackage Fuseki I think as long as you modify the existing
BuiltinRegistry.

Maybe there is also some other kind of plugin system here, but that can
only be answered by Andy, Dave, Adam, etc.


[1] https://issues.apache.org/jira/browse/JENA-1204

>
> Many thanks,
> Pierre
>
>
> From: Lorenz B. [mailto:buehm...@informatik.uni-leipzig.de]
> Sent: 16 May 2019 08:33
> To: users@jena.apache.org
> Subject: Re: Documentation/tutorial on using dates in Jena rules with 
> GenericRuleReasoner
>
> I'm not aware of any tutorial, but afaik you can't do what you did here
> with SPARQL in Jena rules without writing custom built-ins or by
> extending the existing ones because:
>
> * the "difference" built-in does only work for numbers right now [1]
>
> * there is no support for duration type at all it looks like
>
>
> So, so far you could only compare datetime values via lessThan, le,
> greaterThan, ge but there is no other built-in with support for date
> values so far. Others might indeed correct me if I'm wrong of.
>
>
> It looks like, you have to extend the rule system by custom built-ins -
> it's not that difficult though [2]
>
> [1]
> https://github.com/apache/jena/blob/master/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/builtins/Difference.java#L68<https://github.com/apache/jena/blob/master/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/builtins/Difference.java#L68>
> [2] 
> https://jena.apache.org/documentation/inference/#builtins<https://jena.apache.org/documentati

RE: Documentation/tutorial on using dates in Jena rules with GenericRuleReasoner

2019-05-16 Thread Pierre Grenon
Hi Lorenz,

Thank you for your answer.

Quick follow up.

I think the issue for me is the documentation of the built-ins is too abstract 
or relies on understanding the source code. So I suppose, documentation / 
tutorial seems somewhat superfluous when you can do that – only I can’t 
understand what’s there and the source at the moment.



1.  Yes, I seem to understand difference is a no go but I was wondering if 
there might be some work around coercing the dateTime to something else. I’m 
not sure I understood that very well but it looks like I can’t use functions in 
arguments of built-ins (so no xsd:year(?date) or whatever).



But then, on greaterThan, something should be workable if I have xsd:dateTime, 
no?

What’s wrong with :



[ruleMissedDeadline2:

(?conference ns:hasDeadline ?date)

now(?now)

greaterThan(?now, ?date)

->

(?conference ns:status ns:DeadlinePassed)

]

2. When you say extend the rule system, you mean adding a class using as a 
starting point something is in ..rulesys.builtins and adapting it and then 
rebuild all the jars. I’m using Fuseki, so I’d have to rebuild that too, yeah? 
Aside from the fact I’m not coding in java, this isn’t the easiest path for me 
at the moment.

Many thanks,
Pierre


From: Lorenz B. [mailto:buehm...@informatik.uni-leipzig.de]
Sent: 16 May 2019 08:33
To: users@jena.apache.org
Subject: Re: Documentation/tutorial on using dates in Jena rules with 
GenericRuleReasoner

I'm not aware of any tutorial, but afaik you can't do what you did here
with SPARQL in Jena rules without writing custom built-ins or by
extending the existing ones because:

* the "difference" built-in does only work for numbers right now [1]

* there is no support for duration type at all it looks like


So, so far you could only compare datetime values via lessThan, le,
greaterThan, ge but there is no other built-in with support for date
values so far. Others might indeed correct me if I'm wrong of.


It looks like, you have to extend the rule system by custom built-ins -
it's not that difficult though [2]

[1]
https://github.com/apache/jena/blob/master/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/builtins/Difference.java#L68<https://github.com/apache/jena/blob/master/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/builtins/Difference.java#L68>
[2] 
https://jena.apache.org/documentation/inference/#builtins<https://jena.apache.org/documentation/inference/#builtins>

> Could people recommend a good reference/tutorial on how to use built-ins 
> (greaterThan, difference, now etc) with dates (e.g., datetime, duration and 
> so on) in rules for the GenericRuleReasoner?
>
> Example:
>
> Assume a KB of conferences with their deadlines as xsd:dateTime.
>
> Here are examples of SPARQL queries to find conferences whose deadlines are 
> passed:
>
> SELECT * WHERE {
> ?subject here:hasDeadline ?date .
> BIND((xsd:dateTime(?date) - now()) AS ?Span)
> FILTER(?Span < "P0D"^^xsd:duration)
> }
>
> SELECT * WHERE {
> ?subject here:hasDeadline ?date .
> FILTER(now() > xsd:dateTime(?date))
> }
>
> Suppose instead I wanted to infer some attribute of the conference, e.g:
>
> ?subject here:hasStatus here:DeadlinePassed
>
> I don't really get how to do that in a rule and I can't quite figure if I'm 
> misusing the built-ins or just mixing SPARQL and rule syntax (e.g., when 
> trying to coerce variables to datatypes).
>
> There's a bunch of recurring questions around that sort of rules but I can't 
> quite find any answer that's giving clear examples.
>
> Thus I would find it useful if anybody could point at a resource that goes 
> through some sort of how to do date comparison and use that in rules as the 
> Jena doc on built-in is not self-contained in that respect.
>
> https://jena.apache.org/documentation/inference/#rules<https://jena.apache.org/documentation/inference/#rules>
>
>
> With many thanks and kind regards,
> Pierre
>

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

THIS E-MAIL MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION. 
IF YOU ARE NOT THE INTENDED RECIPIENT (OR HAVE RECEIVED THIS E-MAIL 
IN ERROR) PLEASE NOTIFY THE SENDER IMMEDIATELY AND DESTROY THIS 
E-MAIL. ANY UNAUTHORISED COPYING, DISCLOSURE OR DISTRIBUTION OF THE 
MATERIAL IN THIS E-MAIL IS STRICTLY FORBIDDEN. 

IN ACCORDANCE WITH MIFID II RULES ON INDUCEMENTS, THE FIRM'S EMPLOYEES 
MAY ATTEND CORPORATE ACCESS EVENTS (DEFINED IN THE FCA HANDBOOK AS 
"THE SERVICE OF ARRANGING OR BRINGING ABOUT CONTACT BETWEEN AN INVESTMENT 
MANAGER AND AN ISSUER OR POTENTIAL ISSUER"). DURING SUCH MEETINGS, THE 
FIRM'S EMPLOYEES MAY ON NO ACCOUNT BE IN RECEIPT OF INSIDE INFORMATION 
(AS DESCRIBED 

Re: Documentation/tutorial on using dates in Jena rules with GenericRuleReasoner

2019-05-16 Thread Lorenz B.
I'm not aware of any tutorial, but afaik you can't do what you did here
with SPARQL in Jena rules without writing custom built-ins or by
extending the existing ones because:

* the "difference" built-in does only work for numbers right now [1]

* there is no support for duration type at all it looks like


So, so far you could only compare datetime values via lessThan, le,
greaterThan, ge but there is no other built-in with support for date
values so far. Others might indeed correct me if I'm wrong of.


It looks like, you have to extend the rule system by custom built-ins -
it's not that difficult though [2]

[1]
https://github.com/apache/jena/blob/master/jena-core/src/main/java/org/apache/jena/reasoner/rulesys/builtins/Difference.java#L68
[2] https://jena.apache.org/documentation/inference/#builtins

> Could people recommend a good reference/tutorial on how to use built-ins 
> (greaterThan, difference, now etc) with dates (e.g., datetime, duration and 
> so on) in rules for the GenericRuleReasoner?
>
> Example: 
>
> Assume a KB of conferences with their deadlines as xsd:dateTime. 
>
> Here are examples of SPARQL queries to find conferences whose deadlines are 
> passed:
>
> SELECT * WHERE { 
>   ?subject here:hasDeadline ?date . 
>   BIND((xsd:dateTime(?date) - now()) AS ?Span)
>   FILTER(?Span < "P0D"^^xsd:duration)
>   } 
>
> SELECT * WHERE { 
>   ?subject here:hasDeadline ?date . 
>   FILTER(now() > xsd:dateTime(?date)) 
>   }
>
> Suppose instead I wanted to infer some attribute of the conference, e.g: 
>
> ?subject here:hasStatus here:DeadlinePassed 
>
> I don't really get how to do that in a rule and I can't quite figure if I'm 
> misusing the built-ins or just mixing SPARQL and rule syntax (e.g., when 
> trying to coerce variables to datatypes). 
>
> There's a bunch of recurring questions around that sort of rules but I can't 
> quite find any answer that's giving clear examples. 
>
> Thus I would find it useful if anybody could point at a resource that goes 
> through some sort of how to do date comparison and use that in rules as the 
> Jena doc on built-in is not self-contained in that respect.
>
> https://jena.apache.org/documentation/inference/#rules
>
>
> With many thanks and kind regards, 
> Pierre
>
> THIS E-MAIL MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION. 
> IF YOU ARE NOT THE INTENDED RECIPIENT (OR HAVE RECEIVED THIS E-MAIL 
> IN ERROR) PLEASE NOTIFY THE SENDER IMMEDIATELY AND DESTROY THIS 
> E-MAIL. ANY UNAUTHORISED COPYING, DISCLOSURE OR DISTRIBUTION OF THE 
> MATERIAL IN THIS E-MAIL IS STRICTLY FORBIDDEN. 
>
> IN ACCORDANCE WITH MIFID II RULES ON INDUCEMENTS, THE FIRM'S EMPLOYEES 
> MAY ATTEND CORPORATE ACCESS EVENTS (DEFINED IN THE FCA HANDBOOK AS 
> "THE SERVICE OF ARRANGING OR BRINGING ABOUT CONTACT BETWEEN AN INVESTMENT 
> MANAGER AND AN ISSUER OR POTENTIAL ISSUER"). DURING SUCH MEETINGS, THE 
> FIRM'S EMPLOYEES MAY ON NO ACCOUNT BE IN RECEIPT OF INSIDE INFORMATION 
> (AS DESCRIBED IN ARTICLE 7 OF THE MARKET ABUSE REGULATION (EU) NO 596/2014). 
> (https://www.handbook.fca.org.uk/handbook/glossary/G3532m.html)
> COMPANIES WHO DISCLOSE INSIDE INFORMATION ARE IN BREACH OF REGULATION 
> AND MUST IMMEDIATELY AND CLEARLY NOTIFY ALL ATTENDEES. FOR INFORMATION 
> ON THE FIRM'S POLICY IN RELATION TO ITS PARTICIPATION IN MARKET SOUNDINGS, 
> PLEASE SEE https://www.horizon-asset.co.uk/market-soundings/. 
>
> HORIZON ASSET LLP IS AUTHORISED AND REGULATED 
> BY THE FINANCIAL CONDUCT AUTHORITY.
>
>
>
-- 
Lorenz Bühmann
AKSW group, University of Leipzig
Group: http://aksw.org - semantic web research center



Documentation/tutorial on using dates in Jena rules with GenericRuleReasoner

2019-05-15 Thread Pierre Grenon
Hello, 

Could people recommend a good reference/tutorial on how to use built-ins 
(greaterThan, difference, now etc) with dates (e.g., datetime, duration and so 
on) in rules for the GenericRuleReasoner?

Example: 

Assume a KB of conferences with their deadlines as xsd:dateTime. 

Here are examples of SPARQL queries to find conferences whose deadlines are 
passed:

SELECT * WHERE { 
?subject here:hasDeadline ?date . 
BIND((xsd:dateTime(?date) - now()) AS ?Span)
FILTER(?Span < "P0D"^^xsd:duration)
} 

SELECT * WHERE { 
?subject here:hasDeadline ?date . 
FILTER(now() > xsd:dateTime(?date)) 
}

Suppose instead I wanted to infer some attribute of the conference, e.g: 

?subject here:hasStatus here:DeadlinePassed 

I don't really get how to do that in a rule and I can't quite figure if I'm 
misusing the built-ins or just mixing SPARQL and rule syntax (e.g., when trying 
to coerce variables to datatypes). 

There's a bunch of recurring questions around that sort of rules but I can't 
quite find any answer that's giving clear examples. 

Thus I would find it useful if anybody could point at a resource that goes 
through some sort of how to do date comparison and use that in rules as the 
Jena doc on built-in is not self-contained in that respect.

https://jena.apache.org/documentation/inference/#rules


With many thanks and kind regards, 
Pierre

THIS E-MAIL MAY CONTAIN CONFIDENTIAL AND/OR PRIVILEGED INFORMATION. 
IF YOU ARE NOT THE INTENDED RECIPIENT (OR HAVE RECEIVED THIS E-MAIL 
IN ERROR) PLEASE NOTIFY THE SENDER IMMEDIATELY AND DESTROY THIS 
E-MAIL. ANY UNAUTHORISED COPYING, DISCLOSURE OR DISTRIBUTION OF THE 
MATERIAL IN THIS E-MAIL IS STRICTLY FORBIDDEN. 

IN ACCORDANCE WITH MIFID II RULES ON INDUCEMENTS, THE FIRM'S EMPLOYEES 
MAY ATTEND CORPORATE ACCESS EVENTS (DEFINED IN THE FCA HANDBOOK AS 
"THE SERVICE OF ARRANGING OR BRINGING ABOUT CONTACT BETWEEN AN INVESTMENT 
MANAGER AND AN ISSUER OR POTENTIAL ISSUER"). DURING SUCH MEETINGS, THE 
FIRM'S EMPLOYEES MAY ON NO ACCOUNT BE IN RECEIPT OF INSIDE INFORMATION 
(AS DESCRIBED IN ARTICLE 7 OF THE MARKET ABUSE REGULATION (EU) NO 596/2014). 
(https://www.handbook.fca.org.uk/handbook/glossary/G3532m.html)
COMPANIES WHO DISCLOSE INSIDE INFORMATION ARE IN BREACH OF REGULATION 
AND MUST IMMEDIATELY AND CLEARLY NOTIFY ALL ATTENDEES. FOR INFORMATION 
ON THE FIRM'S POLICY IN RELATION TO ITS PARTICIPATION IN MARKET SOUNDINGS, 
PLEASE SEE https://www.horizon-asset.co.uk/market-soundings/. 

HORIZON ASSET LLP IS AUTHORISED AND REGULATED 
BY THE FINANCIAL CONDUCT AUTHORITY.




Re: SWRL Rules

2018-07-10 Thread Lorenz Buehmann
By the way, how do you "run" the SWRL rule in Jena?


On 10.07.2018 19:58, paulo.prsdeso...@gmail.com wrote:
> Hi, 
>
> I'm Paulo Roberto and will like to know how to identify the SWRL rule that 
> was used to generate the inference. I  created a custom built-in for this 
> task, but will like was know if there are other means



Re: SWRL Rules

2018-07-10 Thread Lorenz Buehmann



On 10.07.2018 19:58, paulo.prsdeso...@gmail.com wrote:
> but will like was know if there are other means
what does this mean? it's not a proper English sentence or at least I
don't understand it.


SWRL Rules

2018-07-10 Thread paulo . prsdesouza
Hi, 

I'm Paulo Roberto and will like to know how to identify the SWRL rule that was 
used to generate the inference. I  created a custom built-in for this task, but 
will like was know if there are other means


Re: Rules and machine learning

2018-01-23 Thread javed khan
Thank you Lorenz.

And sorry for the off-topic query.



<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Tue, Jan 23, 2018 at 10:59 AM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> > The
> > following is a paper which used "inconsistency detection" but not used
> ML.
> I know the authors and the paper. Your statement is not correct, in fact
> they used machine learning to find new schema axioms to be added the
> DBpedia ontology, in particular disjointness axioms which are quite
> often a "good" source for inconsistency.
>
> There are also other groups that already used machine learning to
> "replace" standard reasoning procedures.
>
> But again, it's too much off-topic here.
>
>
> On 22.01.2018 17:56, javed khan wrote:
> > Martin, thanks a lot. Its very useful for me..
> >
> > I think it will be possible also to predict inconsistencies in ontologies
> > (via machine learning). It could be my research project which is about to
> > start but the problem is I cant find anything related on the web. The
> > following is a paper which used "inconsistency detection" but not used
> ML.
> >
> > [1]
> > https://hpi.de/fileadmin/user_upload/fachgebiete/meinel/
> papers/Web_3.0/2012_Toepper_ISEM.pdf
> >
> >
> >
> > <https://www.avast.com/sig-email?utm_medium=email&utm_
> source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
> > Virus-free.
> > www.avast.com
> > <https://www.avast.com/sig-email?utm_medium=email&utm_
> source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
> > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> >
> > On Mon, Jan 22, 2018 at 6:52 PM, Martin Vachovski <
> > martin.vachov...@skytek.com> wrote:
> >
> >> Hi all,
> >>
> >> I have seen some papers on "ontology matching"
> >> which is to say- apply a ML algorithm in order to "map"
> >> the semantics of two different ontologies which apply to the same object
> >>
> >> https://homes.cs.washington.edu/~pedrod/papers/hois.pdf
> >> http://disi.unitn.it/~p2p/RelatedWork/Matching/0411csit10.pdf
> >>
> >> While the examples are not exactly the ones seek by the question, they
> >> show that the idea of combining of ML and semantic data storage is not
> new
> >> Hope that points towards the right direction
> >>
> >> Cheers
> >> Martin
> >>
> >>
> >> 
> >> From: javed khan 
> >> Sent: Monday, January 22, 2018 3:12 PM
> >> To: users@jena.apache.org
> >> Subject: Re: Rules and machine learning
> >>
> >> Thank you Lorenz.. Yes rules can not be consider machine learning as
> its a
> >> kind of hard coding and machine will not learn by itself..
> >>
> >>
> >>
> >> <https://www.avast.com/sig-email?utm_medium=email&utm_
> >> source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
> >> Virus-free.
> >> www.avast.com
> >> <https://www.avast.com/sig-email?utm_medium=email&utm_
> >> source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
> >> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> >>
> >> On Mon, Jan 22, 2018 at 7:35 AM, Lorenz Buehmann <
> >> buehm...@informatik.uni-leipzig.de> wrote:
> >>
> >>> I've just some very minimal experience in machine learning and rule
> >>> processing...
> >>>
> >>> The important keywords here are "machine" and "learning" - if you
> >>> provide a set of rules, then there was no learning. Except by the human
> >>> who used his/her knowledge to make the rules - if it's done by a
> >>> "machine", then you can call this machine learning of such rules (e.g.
> >>> rule induction) and use the rules to "infer" data - not predict. The
> >>> rules are just a (human-readable) way to encode the machine learning
> >> model.
> >>> But, it's off-topic for sure, thus, I will not go further into details.
> >>>

Re: Rules and machine learning

2018-01-22 Thread Lorenz Buehmann
> The
> following is a paper which used "inconsistency detection" but not used ML.
I know the authors and the paper. Your statement is not correct, in fact
they used machine learning to find new schema axioms to be added the
DBpedia ontology, in particular disjointness axioms which are quite
often a "good" source for inconsistency.

There are also other groups that already used machine learning to
"replace" standard reasoning procedures.

But again, it's too much off-topic here.


On 22.01.2018 17:56, javed khan wrote:
> Martin, thanks a lot. Its very useful for me..
>
> I think it will be possible also to predict inconsistencies in ontologies
> (via machine learning). It could be my research project which is about to
> start but the problem is I cant find anything related on the web. The
> following is a paper which used "inconsistency detection" but not used ML.
>
> [1]
> https://hpi.de/fileadmin/user_upload/fachgebiete/meinel/papers/Web_3.0/2012_Toepper_ISEM.pdf
>
>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
> Virus-free.
> www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> On Mon, Jan 22, 2018 at 6:52 PM, Martin Vachovski <
> martin.vachov...@skytek.com> wrote:
>
>> Hi all,
>>
>> I have seen some papers on "ontology matching"
>> which is to say- apply a ML algorithm in order to "map"
>> the semantics of two different ontologies which apply to the same object
>>
>> https://homes.cs.washington.edu/~pedrod/papers/hois.pdf
>> http://disi.unitn.it/~p2p/RelatedWork/Matching/0411csit10.pdf
>>
>> While the examples are not exactly the ones seek by the question, they
>> show that the idea of combining of ML and semantic data storage is not new
>> Hope that points towards the right direction
>>
>> Cheers
>> Martin
>>
>>
>> 
>> From: javed khan 
>> Sent: Monday, January 22, 2018 3:12 PM
>> To: users@jena.apache.org
>> Subject: Re: Rules and machine learning
>>
>> Thank you Lorenz.. Yes rules can not be consider machine learning as its a
>> kind of hard coding and machine will not learn by itself..
>>
>>
>>
>> <https://www.avast.com/sig-email?utm_medium=email&utm_
>> source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
>> Virus-free.
>> www.avast.com
>> <https://www.avast.com/sig-email?utm_medium=email&utm_
>> source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
>> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>
>> On Mon, Jan 22, 2018 at 7:35 AM, Lorenz Buehmann <
>> buehm...@informatik.uni-leipzig.de> wrote:
>>
>>> I've just some very minimal experience in machine learning and rule
>>> processing...
>>>
>>> The important keywords here are "machine" and "learning" - if you
>>> provide a set of rules, then there was no learning. Except by the human
>>> who used his/her knowledge to make the rules - if it's done by a
>>> "machine", then you can call this machine learning of such rules (e.g.
>>> rule induction) and use the rules to "infer" data - not predict. The
>>> rules are just a (human-readable) way to encode the machine learning
>> model.
>>> But, it's off-topic for sure, thus, I will not go further into details.
>>>
>>>
>>> Lorenz
>>>
>>>
>>> On 21.01.2018 14:50, javed khan wrote:
>>>> Hello
>>>>
>>>> I am not sure if the question is related to the jena group but I will
>>>> appreciate the answer.
>>>>
>>>> I want to ask is it possible we take the functionality of machine
>>> learning
>>>> techniques (bayes algorithm, decision tree etc) using semantic web
>>> rules. I
>>>> dont know much about machine learning but I know it makes prediction
>>> based
>>>> on past experience/past data.
>>>>
>>>> Like we provide set of rules based on past data (if this, then that)
>> and
>>>> make predictions/optimizations. For instance, we want to make bug
>>>> predictions in a software using Semantic rules, so is it possible??
>>>>
>>>> Thank you
>>>>
>>>> <https://www.avast.com/sig-email?utm_medium=email&utm_
>>> source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
>>>> Virus-free.
>>>> www.avast.com
>>>> <https://www.avast.com/sig-email?utm_medium=email&utm_
>>> source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
>>>> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>>>>
>>>
>>>



Re: Rules and machine learning

2018-01-22 Thread javed khan
Martin, thanks a lot. Its very useful for me..

I think it will be possible also to predict inconsistencies in ontologies
(via machine learning). It could be my research project which is about to
start but the problem is I cant find anything related on the web. The
following is a paper which used "inconsistency detection" but not used ML.

[1]
https://hpi.de/fileadmin/user_upload/fachgebiete/meinel/papers/Web_3.0/2012_Toepper_ISEM.pdf



<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Mon, Jan 22, 2018 at 6:52 PM, Martin Vachovski <
martin.vachov...@skytek.com> wrote:

> Hi all,
>
> I have seen some papers on "ontology matching"
> which is to say- apply a ML algorithm in order to "map"
> the semantics of two different ontologies which apply to the same object
>
> https://homes.cs.washington.edu/~pedrod/papers/hois.pdf
> http://disi.unitn.it/~p2p/RelatedWork/Matching/0411csit10.pdf
>
> While the examples are not exactly the ones seek by the question, they
> show that the idea of combining of ML and semantic data storage is not new
> Hope that points towards the right direction
>
> Cheers
> Martin
>
>
> ____
> From: javed khan 
> Sent: Monday, January 22, 2018 3:12 PM
> To: users@jena.apache.org
> Subject: Re: Rules and machine learning
>
> Thank you Lorenz.. Yes rules can not be consider machine learning as its a
> kind of hard coding and machine will not learn by itself..
>
>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_
> source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
> Virus-free.
> www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_
> source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>
> On Mon, Jan 22, 2018 at 7:35 AM, Lorenz Buehmann <
> buehm...@informatik.uni-leipzig.de> wrote:
>
> > I've just some very minimal experience in machine learning and rule
> > processing...
> >
> > The important keywords here are "machine" and "learning" - if you
> > provide a set of rules, then there was no learning. Except by the human
> > who used his/her knowledge to make the rules - if it's done by a
> > "machine", then you can call this machine learning of such rules (e.g.
> > rule induction) and use the rules to "infer" data - not predict. The
> > rules are just a (human-readable) way to encode the machine learning
> model.
> >
> > But, it's off-topic for sure, thus, I will not go further into details.
> >
> >
> > Lorenz
> >
> >
> > On 21.01.2018 14:50, javed khan wrote:
> > > Hello
> > >
> > > I am not sure if the question is related to the jena group but I will
> > > appreciate the answer.
> > >
> > > I want to ask is it possible we take the functionality of machine
> > learning
> > > techniques (bayes algorithm, decision tree etc) using semantic web
> > rules. I
> > > dont know much about machine learning but I know it makes prediction
> > based
> > > on past experience/past data.
> > >
> > > Like we provide set of rules based on past data (if this, then that)
> and
> > > make predictions/optimizations. For instance, we want to make bug
> > > predictions in a software using Semantic rules, so is it possible??
> > >
> > > Thank you
> > >
> > > <https://www.avast.com/sig-email?utm_medium=email&utm_
> > source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
> > > Virus-free.
> > > www.avast.com
> > > <https://www.avast.com/sig-email?utm_medium=email&utm_
> > source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
> > > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> > >
> >
> >
> >
>


Re: Rules and machine learning

2018-01-22 Thread Martin Vachovski
Hi all,

I have seen some papers on "ontology matching"
which is to say- apply a ML algorithm in order to "map"
the semantics of two different ontologies which apply to the same object

https://homes.cs.washington.edu/~pedrod/papers/hois.pdf
http://disi.unitn.it/~p2p/RelatedWork/Matching/0411csit10.pdf

While the examples are not exactly the ones seek by the question, they show 
that the idea of combining of ML and semantic data storage is not new
Hope that points towards the right direction

Cheers
Martin



From: javed khan 
Sent: Monday, January 22, 2018 3:12 PM
To: users@jena.apache.org
Subject: Re: Rules and machine learning

Thank you Lorenz.. Yes rules can not be consider machine learning as its a
kind of hard coding and machine will not learn by itself..



<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Mon, Jan 22, 2018 at 7:35 AM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> I've just some very minimal experience in machine learning and rule
> processing...
>
> The important keywords here are "machine" and "learning" - if you
> provide a set of rules, then there was no learning. Except by the human
> who used his/her knowledge to make the rules - if it's done by a
> "machine", then you can call this machine learning of such rules (e.g.
> rule induction) and use the rules to "infer" data - not predict. The
> rules are just a (human-readable) way to encode the machine learning model.
>
> But, it's off-topic for sure, thus, I will not go further into details.
>
>
> Lorenz
>
>
> On 21.01.2018 14:50, javed khan wrote:
> > Hello
> >
> > I am not sure if the question is related to the jena group but I will
> > appreciate the answer.
> >
> > I want to ask is it possible we take the functionality of machine
> learning
> > techniques (bayes algorithm, decision tree etc) using semantic web
> rules. I
> > dont know much about machine learning but I know it makes prediction
> based
> > on past experience/past data.
> >
> > Like we provide set of rules based on past data (if this, then that) and
> > make predictions/optimizations. For instance, we want to make bug
> > predictions in a software using Semantic rules, so is it possible??
> >
> > Thank you
> >
> > <https://www.avast.com/sig-email?utm_medium=email&utm_
> source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
> > Virus-free.
> > www.avast.com
> > <https://www.avast.com/sig-email?utm_medium=email&utm_
> source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
> > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> >
>
>
>


Re: Rules and machine learning

2018-01-22 Thread javed khan
Thank you Lorenz.. Yes rules can not be consider machine learning as its a
kind of hard coding and machine will not learn by itself..



<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Mon, Jan 22, 2018 at 7:35 AM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> I've just some very minimal experience in machine learning and rule
> processing...
>
> The important keywords here are "machine" and "learning" - if you
> provide a set of rules, then there was no learning. Except by the human
> who used his/her knowledge to make the rules - if it's done by a
> "machine", then you can call this machine learning of such rules (e.g.
> rule induction) and use the rules to "infer" data - not predict. The
> rules are just a (human-readable) way to encode the machine learning model.
>
> But, it's off-topic for sure, thus, I will not go further into details.
>
>
> Lorenz
>
>
> On 21.01.2018 14:50, javed khan wrote:
> > Hello
> >
> > I am not sure if the question is related to the jena group but I will
> > appreciate the answer.
> >
> > I want to ask is it possible we take the functionality of machine
> learning
> > techniques (bayes algorithm, decision tree etc) using semantic web
> rules. I
> > dont know much about machine learning but I know it makes prediction
> based
> > on past experience/past data.
> >
> > Like we provide set of rules based on past data (if this, then that) and
> > make predictions/optimizations. For instance, we want to make bug
> > predictions in a software using Semantic rules, so is it possible??
> >
> > Thank you
> >
> > <https://www.avast.com/sig-email?utm_medium=email&utm_
> source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
> > Virus-free.
> > www.avast.com
> > <https://www.avast.com/sig-email?utm_medium=email&utm_
> source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
> > <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
> >
>
>
>


Re: Rules and machine learning

2018-01-21 Thread Lorenz Buehmann
I've just some very minimal experience in machine learning and rule
processing...

The important keywords here are "machine" and "learning" - if you
provide a set of rules, then there was no learning. Except by the human
who used his/her knowledge to make the rules - if it's done by a
"machine", then you can call this machine learning of such rules (e.g.
rule induction) and use the rules to "infer" data - not predict. The
rules are just a (human-readable) way to encode the machine learning model.

But, it's off-topic for sure, thus, I will not go further into details.


Lorenz


On 21.01.2018 14:50, javed khan wrote:
> Hello
>
> I am not sure if the question is related to the jena group but I will
> appreciate the answer.
>
> I want to ask is it possible we take the functionality of machine learning
> techniques (bayes algorithm, decision tree etc) using semantic web rules. I
> dont know much about machine learning but I know it makes prediction based
> on past experience/past data.
>
> Like we provide set of rules based on past data (if this, then that) and
> make predictions/optimizations. For instance, we want to make bug
> predictions in a software using Semantic rules, so is it possible??
>
> Thank you
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
> Virus-free.
> www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
> <#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>
>




Rules and machine learning

2018-01-21 Thread javed khan
Hello

I am not sure if the question is related to the jena group but I will
appreciate the answer.

I want to ask is it possible we take the functionality of machine learning
techniques (bayes algorithm, decision tree etc) using semantic web rules. I
dont know much about machine learning but I know it makes prediction based
on past experience/past data.

Like we provide set of rules based on past data (if this, then that) and
make predictions/optimizations. For instance, we want to make bug
predictions in a software using Semantic rules, so is it possible??

Thank you

<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=icon>
Virus-free.
www.avast.com
<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail&utm_term=link>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>


Re: Construct query for Rules

2017-09-14 Thread javed khan
Thank you Lorenz for your help.



On Thu, Sep 14, 2017 at 8:30 AM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

>
>
> On 14.09.2017 15:15, javed khan wrote:
> > Hello Lorenz, I have class Student which have sub classes "Researcher (if
> > publication>10), Assistant (if publications >7) and Junior Student. The
> > instances of these classes are assigned using Construct query as shown in
> > my previous email.
> >
> > I want to store it also in file as other data of students name,
> department
> > etc are already in the file. Earlier I used Jena rules and it was stored
> in
> > the file.
> >
> > **If you want to have the additional triples in the same file, you
> > have to add the triples to the original model and write this model back
> > to file.
> >
> > It means Lorenz, I have to add the "results" model Of Construct query to
> > the other model which have all other data and then store/write it to the
> > file?
> >
> > model.add(results)
> Yes, this should be quite obvious: you have a model A which is basically
> a set of triples and based on this model you compute a new model B
> containing another, possibly new set of triples. Indeed, you want to
> have the union of both, thus, add B to A.
> An alternative would be directly modify model A by means of a SPARQL
> update query, but it wouldn't change the overall result.
> >
> > On Thu, Sep 14, 2017 at 3:07 PM, Lorenz Buehmann <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >>
> >> On 12.09.2017 22:01, javed khan wrote:
> >>> Andy, Dave, Lorenz thanks a lot for your help. I removed the comma and
> it
> >>> works.
> >>>
> >>> But to write it to the file, we have the OntModel (model1) as:
> >>>
> >>> try (FileOutputStream writer = new FileOutputStream("F://exp.owl")) {
> >>>   model1.write(writer, "RDF/XML");
> >>>
> >>> But after we run the Construct query, we will have another model like:
> >>>
> >>> Model results= qexec.execConstruct() ;
> >>> results.write(System.out, "TURTLE");
> >> That model contains only the new triples, not the old ones.
> >>> So we should write it separate to the file? I tried this but it did not
> >>> work. In fact, it over-write the already data in the file.
> >> I don't get it as I don't understand what you want to achieve in the
> >> end. If you want to have the additional triples in the same file, you
> >> have to add the triples to the original model and write this model back
> >> to file.
> >>
> >>> //The query work fine if we write to console.
> >>>
> >>> On Tue, Sep 12, 2017 at 1:45 PM, Lorenz Buehmann <
> >>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>
> >>>>> "FILTER ( ?score > '10' ). "   // is this right syntax in Jena?
> >>>> That has nothing to do with Jena - It's SPARQL syntax and as Dave
> >>>> already pointed out,
> >>>> '10' is a string literal - either use "10"^^xsd:integer or the
> shortcut
> >>>> 10 . See the Turtle syntax for RDF and look into the SPARQL specs.
> >>>>> On Mon, Sep 11, 2017 at 3:17 PM, Lorenz Buehmann <
> >>>>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>>>
> >>>>>> Show code + data, otherwise nobody can help you ...
> >>>>>>
> >>>>>> That's the simplest way, a SPARQL query for each rule - don't make
> it
> >>>>>> more complicated as necessary.
> >>>>>>
> >>>>>> Don't forget (Dave and me already told you that): if you have
> multiple
> >>>>>> rules that depend on each other, you have to perform the SPARQL
> >> queries
> >>>>>> as long as no new data has been generated ("fix-point iteration") -
> >> with
> >>>>>> rules you get this for free by the rule engine.
> >>>>>>
> >>>>>>
> >>>>>> On 11.09.2017 13:09, javed khan wrote:
> >>>>>>> Hello Lorenz yes it did not work for me. İ have about sixteen
> similar
> >>>>>> types
> >>>>>>> of rules and not sure if İ need a separate SPARQL Construct query
> for
> >>>>>> each
>

Re: Construct query for Rules

2017-09-14 Thread Lorenz Buehmann


On 14.09.2017 15:15, javed khan wrote:
> Hello Lorenz, I have class Student which have sub classes "Researcher (if
> publication>10), Assistant (if publications >7) and Junior Student. The
> instances of these classes are assigned using Construct query as shown in
> my previous email.
>
> I want to store it also in file as other data of students name, department
> etc are already in the file. Earlier I used Jena rules and it was stored in
> the file.
>
> **If you want to have the additional triples in the same file, you
> have to add the triples to the original model and write this model back
> to file.
>
> It means Lorenz, I have to add the "results" model Of Construct query to
> the other model which have all other data and then store/write it to the
> file?
>
> model.add(results)
Yes, this should be quite obvious: you have a model A which is basically
a set of triples and based on this model you compute a new model B
containing another, possibly new set of triples. Indeed, you want to
have the union of both, thus, add B to A.
An alternative would be directly modify model A by means of a SPARQL
update query, but it wouldn't change the overall result.
>
> On Thu, Sep 14, 2017 at 3:07 PM, Lorenz Buehmann <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>>
>> On 12.09.2017 22:01, javed khan wrote:
>>> Andy, Dave, Lorenz thanks a lot for your help. I removed the comma and it
>>> works.
>>>
>>> But to write it to the file, we have the OntModel (model1) as:
>>>
>>> try (FileOutputStream writer = new FileOutputStream("F://exp.owl")) {
>>>   model1.write(writer, "RDF/XML");
>>>
>>> But after we run the Construct query, we will have another model like:
>>>
>>> Model results= qexec.execConstruct() ;
>>> results.write(System.out, "TURTLE");
>> That model contains only the new triples, not the old ones.
>>> So we should write it separate to the file? I tried this but it did not
>>> work. In fact, it over-write the already data in the file.
>> I don't get it as I don't understand what you want to achieve in the
>> end. If you want to have the additional triples in the same file, you
>> have to add the triples to the original model and write this model back
>> to file.
>>
>>> //The query work fine if we write to console.
>>>
>>> On Tue, Sep 12, 2017 at 1:45 PM, Lorenz Buehmann <
>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>
>>>>> "FILTER ( ?score > '10' ). "   // is this right syntax in Jena?
>>>> That has nothing to do with Jena - It's SPARQL syntax and as Dave
>>>> already pointed out,
>>>> '10' is a string literal - either use "10"^^xsd:integer or the shortcut
>>>> 10 . See the Turtle syntax for RDF and look into the SPARQL specs.
>>>>> On Mon, Sep 11, 2017 at 3:17 PM, Lorenz Buehmann <
>>>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>>>
>>>>>> Show code + data, otherwise nobody can help you ...
>>>>>>
>>>>>> That's the simplest way, a SPARQL query for each rule - don't make it
>>>>>> more complicated as necessary.
>>>>>>
>>>>>> Don't forget (Dave and me already told you that): if you have multiple
>>>>>> rules that depend on each other, you have to perform the SPARQL
>> queries
>>>>>> as long as no new data has been generated ("fix-point iteration") -
>> with
>>>>>> rules you get this for free by the rule engine.
>>>>>>
>>>>>>
>>>>>> On 11.09.2017 13:09, javed khan wrote:
>>>>>>> Hello Lorenz yes it did not work for me. İ have about sixteen similar
>>>>>> types
>>>>>>> of rules and not sure if İ need a separate SPARQL Construct query for
>>>>>> each
>>>>>>> rule.
>>>>>>> For example another such type of rule is if a person experience is
>> more
>>>>>>> than some value, then person is Experience employee and other rules
>>>> like
>>>>>>> that.
>>>>>>>
>>>>>>> On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
>>>>>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>>>>>
>>>>>>>> I thought Dave explained this already. Of course you can use a
>> SPARQL
>>>>>>>> CONSTRUCT query to get the same result as a single Jena rule.
>>>>>>>>
>>>>>>>> The answer is, yes. Your query should do the same as your rule.
>>>>>>>>
>>>>>>>> And I'm wondering why you can't try it out on your data? Does
>>>> something
>>>>>>>> not work as expected?
>>>>>>>>
>>>>>>>>
>>>>>>>> On 10.09.2017 22:15, javed khan wrote:
>>>>>>>>> I am wondering if the following Construct query could lead to the
>>>>>>>> alternate
>>>>>>>>> result of the Jena rule (given below)?
>>>>>>>>>
>>>>>>>>> Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No)
>>>>>> +greaterThan
>>>>>>>>> (?No, 10)-> (?x rdf:type :Researcher)
>>>>>>>>>
>>>>>>>>> Construct Query:
>>>>>>>>>
>>>>>>>>> Construct {?x rdf:type :Researcher}
>>>>>>>>>
>>>>>>>>> Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
>>>>>>>>> (?No>10) }
>>>>>>>>>
>>



Re: Construct query for Rules

2017-09-14 Thread javed khan
Hello Lorenz, I have class Student which have sub classes "Researcher (if
publication>10), Assistant (if publications >7) and Junior Student. The
instances of these classes are assigned using Construct query as shown in
my previous email.

I want to store it also in file as other data of students name, department
etc are already in the file. Earlier I used Jena rules and it was stored in
the file.

**If you want to have the additional triples in the same file, you
have to add the triples to the original model and write this model back
to file.

It means Lorenz, I have to add the "results" model Of Construct query to
the other model which have all other data and then store/write it to the
file?

model.add(results)

On Thu, Sep 14, 2017 at 3:07 PM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

>
>
> On 12.09.2017 22:01, javed khan wrote:
> > Andy, Dave, Lorenz thanks a lot for your help. I removed the comma and it
> > works.
> >
> > But to write it to the file, we have the OntModel (model1) as:
> >
> > try (FileOutputStream writer = new FileOutputStream("F://exp.owl")) {
> >   model1.write(writer, "RDF/XML");
> >
> > But after we run the Construct query, we will have another model like:
> >
> > Model results= qexec.execConstruct() ;
> > results.write(System.out, "TURTLE");
> That model contains only the new triples, not the old ones.
> >
> > So we should write it separate to the file? I tried this but it did not
> > work. In fact, it over-write the already data in the file.
> I don't get it as I don't understand what you want to achieve in the
> end. If you want to have the additional triples in the same file, you
> have to add the triples to the original model and write this model back
> to file.
>
> >
> > //The query work fine if we write to console.
> >
> > On Tue, Sep 12, 2017 at 1:45 PM, Lorenz Buehmann <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >>> "FILTER ( ?score > '10' ). "   // is this right syntax in Jena?
> >> That has nothing to do with Jena - It's SPARQL syntax and as Dave
> >> already pointed out,
> >> '10' is a string literal - either use "10"^^xsd:integer or the shortcut
> >> 10 . See the Turtle syntax for RDF and look into the SPARQL specs.
> >>> On Mon, Sep 11, 2017 at 3:17 PM, Lorenz Buehmann <
> >>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>
> >>>> Show code + data, otherwise nobody can help you ...
> >>>>
> >>>> That's the simplest way, a SPARQL query for each rule - don't make it
> >>>> more complicated as necessary.
> >>>>
> >>>> Don't forget (Dave and me already told you that): if you have multiple
> >>>> rules that depend on each other, you have to perform the SPARQL
> queries
> >>>> as long as no new data has been generated ("fix-point iteration") -
> with
> >>>> rules you get this for free by the rule engine.
> >>>>
> >>>>
> >>>> On 11.09.2017 13:09, javed khan wrote:
> >>>>> Hello Lorenz yes it did not work for me. İ have about sixteen similar
> >>>> types
> >>>>> of rules and not sure if İ need a separate SPARQL Construct query for
> >>>> each
> >>>>> rule.
> >>>>> For example another such type of rule is if a person experience is
> more
> >>>>> than some value, then person is Experience employee and other rules
> >> like
> >>>>> that.
> >>>>>
> >>>>> On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
> >>>>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>>>
> >>>>>> I thought Dave explained this already. Of course you can use a
> SPARQL
> >>>>>> CONSTRUCT query to get the same result as a single Jena rule.
> >>>>>>
> >>>>>> The answer is, yes. Your query should do the same as your rule.
> >>>>>>
> >>>>>> And I'm wondering why you can't try it out on your data? Does
> >> something
> >>>>>> not work as expected?
> >>>>>>
> >>>>>>
> >>>>>> On 10.09.2017 22:15, javed khan wrote:
> >>>>>>> I am wondering if the following Construct query could lead to the
> >>>>>> alternate
> >>>>>>> result of the Jena rule (given below)?
> >>>>>>>
> >>>>>>> Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No)
> >>>> +greaterThan
> >>>>>>> (?No, 10)-> (?x rdf:type :Researcher)
> >>>>>>>
> >>>>>>> Construct Query:
> >>>>>>>
> >>>>>>> Construct {?x rdf:type :Researcher}
> >>>>>>>
> >>>>>>> Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
> >>>>>>> (?No>10) }
> >>>>>>>
> >>
>
>


Re: Construct query for Rules

2017-09-14 Thread Lorenz Buehmann


On 12.09.2017 22:01, javed khan wrote:
> Andy, Dave, Lorenz thanks a lot for your help. I removed the comma and it
> works.
>
> But to write it to the file, we have the OntModel (model1) as:
>
> try (FileOutputStream writer = new FileOutputStream("F://exp.owl")) {
>   model1.write(writer, "RDF/XML");
>
> But after we run the Construct query, we will have another model like:
>
> Model results= qexec.execConstruct() ;
> results.write(System.out, "TURTLE");
That model contains only the new triples, not the old ones.
>
> So we should write it separate to the file? I tried this but it did not
> work. In fact, it over-write the already data in the file.
I don't get it as I don't understand what you want to achieve in the
end. If you want to have the additional triples in the same file, you
have to add the triples to the original model and write this model back
to file.

>
> //The query work fine if we write to console.
>
> On Tue, Sep 12, 2017 at 1:45 PM, Lorenz Buehmann <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>>> "FILTER ( ?score > '10' ). "   // is this right syntax in Jena?
>> That has nothing to do with Jena - It's SPARQL syntax and as Dave
>> already pointed out,
>> '10' is a string literal - either use "10"^^xsd:integer or the shortcut
>> 10 . See the Turtle syntax for RDF and look into the SPARQL specs.
>>> On Mon, Sep 11, 2017 at 3:17 PM, Lorenz Buehmann <
>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>
>>>> Show code + data, otherwise nobody can help you ...
>>>>
>>>> That's the simplest way, a SPARQL query for each rule - don't make it
>>>> more complicated as necessary.
>>>>
>>>> Don't forget (Dave and me already told you that): if you have multiple
>>>> rules that depend on each other, you have to perform the SPARQL queries
>>>> as long as no new data has been generated ("fix-point iteration") - with
>>>> rules you get this for free by the rule engine.
>>>>
>>>>
>>>> On 11.09.2017 13:09, javed khan wrote:
>>>>> Hello Lorenz yes it did not work for me. İ have about sixteen similar
>>>> types
>>>>> of rules and not sure if İ need a separate SPARQL Construct query for
>>>> each
>>>>> rule.
>>>>> For example another such type of rule is if a person experience is more
>>>>> than some value, then person is Experience employee and other rules
>> like
>>>>> that.
>>>>>
>>>>> On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
>>>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>>>
>>>>>> I thought Dave explained this already. Of course you can use a SPARQL
>>>>>> CONSTRUCT query to get the same result as a single Jena rule.
>>>>>>
>>>>>> The answer is, yes. Your query should do the same as your rule.
>>>>>>
>>>>>> And I'm wondering why you can't try it out on your data? Does
>> something
>>>>>> not work as expected?
>>>>>>
>>>>>>
>>>>>> On 10.09.2017 22:15, javed khan wrote:
>>>>>>> I am wondering if the following Construct query could lead to the
>>>>>> alternate
>>>>>>> result of the Jena rule (given below)?
>>>>>>>
>>>>>>> Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No)
>>>> +greaterThan
>>>>>>> (?No, 10)-> (?x rdf:type :Researcher)
>>>>>>>
>>>>>>> Construct Query:
>>>>>>>
>>>>>>> Construct {?x rdf:type :Researcher}
>>>>>>>
>>>>>>> Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
>>>>>>> (?No>10) }
>>>>>>>
>>



Re: Construct query for Rules

2017-09-12 Thread javed khan
Andy, Dave, Lorenz thanks a lot for your help. I removed the comma and it
works.

But to write it to the file, we have the OntModel (model1) as:

try (FileOutputStream writer = new FileOutputStream("F://exp.owl")) {
  model1.write(writer, "RDF/XML");

But after we run the Construct query, we will have another model like:

Model results= qexec.execConstruct() ;
results.write(System.out, "TURTLE");

So we should write it separate to the file? I tried this but it did not
work. In fact, it over-write the already data in the file.

//The query work fine if we write to console.

On Tue, Sep 12, 2017 at 1:45 PM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

>
> > "FILTER ( ?score > '10' ). "   // is this right syntax in Jena?
> That has nothing to do with Jena - It's SPARQL syntax and as Dave
> already pointed out,
> '10' is a string literal - either use "10"^^xsd:integer or the shortcut
> 10 . See the Turtle syntax for RDF and look into the SPARQL specs.
> >
> > On Mon, Sep 11, 2017 at 3:17 PM, Lorenz Buehmann <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> Show code + data, otherwise nobody can help you ...
> >>
> >> That's the simplest way, a SPARQL query for each rule - don't make it
> >> more complicated as necessary.
> >>
> >> Don't forget (Dave and me already told you that): if you have multiple
> >> rules that depend on each other, you have to perform the SPARQL queries
> >> as long as no new data has been generated ("fix-point iteration") - with
> >> rules you get this for free by the rule engine.
> >>
> >>
> >> On 11.09.2017 13:09, javed khan wrote:
> >>> Hello Lorenz yes it did not work for me. İ have about sixteen similar
> >> types
> >>> of rules and not sure if İ need a separate SPARQL Construct query for
> >> each
> >>> rule.
> >>> For example another such type of rule is if a person experience is more
> >>> than some value, then person is Experience employee and other rules
> like
> >>> that.
> >>>
> >>> On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
> >>> buehm...@informatik.uni-leipzig.de> wrote:
> >>>
> >>>> I thought Dave explained this already. Of course you can use a SPARQL
> >>>> CONSTRUCT query to get the same result as a single Jena rule.
> >>>>
> >>>> The answer is, yes. Your query should do the same as your rule.
> >>>>
> >>>> And I'm wondering why you can't try it out on your data? Does
> something
> >>>> not work as expected?
> >>>>
> >>>>
> >>>> On 10.09.2017 22:15, javed khan wrote:
> >>>>> I am wondering if the following Construct query could lead to the
> >>>> alternate
> >>>>> result of the Jena rule (given below)?
> >>>>>
> >>>>> Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No)
> >> +greaterThan
> >>>>> (?No, 10)-> (?x rdf:type :Researcher)
> >>>>>
> >>>>> Construct Query:
> >>>>>
> >>>>> Construct {?x rdf:type :Researcher}
> >>>>>
> >>>>> Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
> >>>>> (?No>10) }
> >>>>>
> >>
>
>


Re: Construct query for Rules

2017-09-12 Thread Lorenz Buehmann

> "FILTER ( ?score > '10' ). "   // is this right syntax in Jena?
That has nothing to do with Jena - It's SPARQL syntax and as Dave
already pointed out,
'10' is a string literal - either use "10"^^xsd:integer or the shortcut
10 . See the Turtle syntax for RDF and look into the SPARQL specs.
>
> On Mon, Sep 11, 2017 at 3:17 PM, Lorenz Buehmann <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>> Show code + data, otherwise nobody can help you ...
>>
>> That's the simplest way, a SPARQL query for each rule - don't make it
>> more complicated as necessary.
>>
>> Don't forget (Dave and me already told you that): if you have multiple
>> rules that depend on each other, you have to perform the SPARQL queries
>> as long as no new data has been generated ("fix-point iteration") - with
>> rules you get this for free by the rule engine.
>>
>>
>> On 11.09.2017 13:09, javed khan wrote:
>>> Hello Lorenz yes it did not work for me. İ have about sixteen similar
>> types
>>> of rules and not sure if İ need a separate SPARQL Construct query for
>> each
>>> rule.
>>> For example another such type of rule is if a person experience is more
>>> than some value, then person is Experience employee and other rules like
>>> that.
>>>
>>> On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
>>> buehm...@informatik.uni-leipzig.de> wrote:
>>>
>>>> I thought Dave explained this already. Of course you can use a SPARQL
>>>> CONSTRUCT query to get the same result as a single Jena rule.
>>>>
>>>> The answer is, yes. Your query should do the same as your rule.
>>>>
>>>> And I'm wondering why you can't try it out on your data? Does something
>>>> not work as expected?
>>>>
>>>>
>>>> On 10.09.2017 22:15, javed khan wrote:
>>>>> I am wondering if the following Construct query could lead to the
>>>> alternate
>>>>> result of the Jena rule (given below)?
>>>>>
>>>>> Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No)
>> +greaterThan
>>>>> (?No, 10)-> (?x rdf:type :Researcher)
>>>>>
>>>>> Construct Query:
>>>>>
>>>>> Construct {?x rdf:type :Researcher}
>>>>>
>>>>> Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
>>>>> (?No>10) }
>>>>>
>>



Re: Construct query for Rules

2017-09-12 Thread Dave Reynolds

On 12/09/17 00:12, javed khan wrote:

Hello Martynas and Lorenz thank you

I have issue about it.  When I use the filter keyword, the query does not
show the result. When I remove the filter, it writes in console that x is
type of researcher (regardless of any number of publications as there is no
filter) So the problem is in Filter syntax in Jena code. I use Filter as

"FILTER ( ?score > '10' ). "   // is this right syntax in Jena?


Assuming score is a integer then no. That's the SPARQL syntax (this is 
not specific to Jena) for a string. You presumably want:


FILTER ( ?score > 10 ).

Dave





On Mon, Sep 11, 2017 at 3:17 PM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:


Show code + data, otherwise nobody can help you ...

That's the simplest way, a SPARQL query for each rule - don't make it
more complicated as necessary.

Don't forget (Dave and me already told you that): if you have multiple
rules that depend on each other, you have to perform the SPARQL queries
as long as no new data has been generated ("fix-point iteration") - with
rules you get this for free by the rule engine.


On 11.09.2017 13:09, javed khan wrote:

Hello Lorenz yes it did not work for me. İ have about sixteen similar

types

of rules and not sure if İ need a separate SPARQL Construct query for

each

rule.
For example another such type of rule is if a person experience is more
than some value, then person is Experience employee and other rules like
that.

On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:


I thought Dave explained this already. Of course you can use a SPARQL
CONSTRUCT query to get the same result as a single Jena rule.

The answer is, yes. Your query should do the same as your rule.

And I'm wondering why you can't try it out on your data? Does something
not work as expected?


On 10.09.2017 22:15, javed khan wrote:

I am wondering if the following Construct query could lead to the

alternate

result of the Jena rule (given below)?

Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No)

+greaterThan

(?No, 10)-> (?x rdf:type :Researcher)

Construct Query:

Construct {?x rdf:type :Researcher}

Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
(?No>10) }










Re: Construct query for Rules

2017-09-11 Thread javed khan
Hello Martynas and Lorenz thank you

I have issue about it.  When I use the filter keyword, the query does not
show the result. When I remove the filter, it writes in console that x is
type of researcher (regardless of any number of publications as there is no
filter) So the problem is in Filter syntax in Jena code. I use Filter as

"FILTER ( ?score > '10' ). "   // is this right syntax in Jena?



On Mon, Sep 11, 2017 at 3:17 PM, Lorenz Buehmann <
buehm...@informatik.uni-leipzig.de> wrote:

> Show code + data, otherwise nobody can help you ...
>
> That's the simplest way, a SPARQL query for each rule - don't make it
> more complicated as necessary.
>
> Don't forget (Dave and me already told you that): if you have multiple
> rules that depend on each other, you have to perform the SPARQL queries
> as long as no new data has been generated ("fix-point iteration") - with
> rules you get this for free by the rule engine.
>
>
> On 11.09.2017 13:09, javed khan wrote:
> > Hello Lorenz yes it did not work for me. İ have about sixteen similar
> types
> > of rules and not sure if İ need a separate SPARQL Construct query for
> each
> > rule.
> > For example another such type of rule is if a person experience is more
> > than some value, then person is Experience employee and other rules like
> > that.
> >
> > On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
> > buehm...@informatik.uni-leipzig.de> wrote:
> >
> >> I thought Dave explained this already. Of course you can use a SPARQL
> >> CONSTRUCT query to get the same result as a single Jena rule.
> >>
> >> The answer is, yes. Your query should do the same as your rule.
> >>
> >> And I'm wondering why you can't try it out on your data? Does something
> >> not work as expected?
> >>
> >>
> >> On 10.09.2017 22:15, javed khan wrote:
> >>> I am wondering if the following Construct query could lead to the
> >> alternate
> >>> result of the Jena rule (given below)?
> >>>
> >>> Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No)
> +greaterThan
> >>> (?No, 10)-> (?x rdf:type :Researcher)
> >>>
> >>> Construct Query:
> >>>
> >>> Construct {?x rdf:type :Researcher}
> >>>
> >>> Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
> >>> (?No>10) }
> >>>
> >>
>
>


Re: Construct query for Rules

2017-09-11 Thread Lorenz Buehmann
Show code + data, otherwise nobody can help you ...

That's the simplest way, a SPARQL query for each rule - don't make it
more complicated as necessary.

Don't forget (Dave and me already told you that): if you have multiple
rules that depend on each other, you have to perform the SPARQL queries
as long as no new data has been generated ("fix-point iteration") - with
rules you get this for free by the rule engine.


On 11.09.2017 13:09, javed khan wrote:
> Hello Lorenz yes it did not work for me. İ have about sixteen similar types
> of rules and not sure if İ need a separate SPARQL Construct query for each
> rule.
> For example another such type of rule is if a person experience is more
> than some value, then person is Experience employee and other rules like
> that.
>
> On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
> buehm...@informatik.uni-leipzig.de> wrote:
>
>> I thought Dave explained this already. Of course you can use a SPARQL
>> CONSTRUCT query to get the same result as a single Jena rule.
>>
>> The answer is, yes. Your query should do the same as your rule.
>>
>> And I'm wondering why you can't try it out on your data? Does something
>> not work as expected?
>>
>>
>> On 10.09.2017 22:15, javed khan wrote:
>>> I am wondering if the following Construct query could lead to the
>> alternate
>>> result of the Jena rule (given below)?
>>>
>>> Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No) +greaterThan
>>> (?No, 10)-> (?x rdf:type :Researcher)
>>>
>>> Construct Query:
>>>
>>> Construct {?x rdf:type :Researcher}
>>>
>>> Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
>>> (?No>10) }
>>>
>>



Re: Construct query for Rules

2017-09-11 Thread Martynas Jusevičius
* not a valid property

On Mon, Sep 11, 2017 at 1:19 PM, Martynas Jusevičius  wrote:

> Javed,
>
> show the data and the errors.
>
> exp: NoOfPublications is property (with space in the middle).
>
> On Mon, Sep 11, 2017 at 1:09 PM, javed khan  wrote:
>
>> Hello Lorenz yes it did not work for me. İ have about sixteen similar
>> types
>> of rules and not sure if İ need a separate SPARQL Construct query for each
>> rule.
>> For example another such type of rule is if a person experience is more
>> than some value, then person is Experience employee and other rules like
>> that.
>>
>> On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
>> buehm...@informatik.uni-leipzig.de> wrote:
>>
>> > I thought Dave explained this already. Of course you can use a SPARQL
>> > CONSTRUCT query to get the same result as a single Jena rule.
>> >
>> > The answer is, yes. Your query should do the same as your rule.
>> >
>> > And I'm wondering why you can't try it out on your data? Does something
>> > not work as expected?
>> >
>> >
>> > On 10.09.2017 22:15, javed khan wrote:
>> > > I am wondering if the following Construct query could lead to the
>> > alternate
>> > > result of the Jena rule (given below)?
>> > >
>> > > Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No)
>> +greaterThan
>> > > (?No, 10)-> (?x rdf:type :Researcher)
>> > >
>> > > Construct Query:
>> > >
>> > > Construct {?x rdf:type :Researcher}
>> > >
>> > > Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
>> > > (?No>10) }
>> > >
>> >
>> >
>>
>
>


Re: Construct query for Rules

2017-09-11 Thread Martynas Jusevičius
Javed,

show the data and the errors.

exp: NoOfPublications is property (with space in the middle).

On Mon, Sep 11, 2017 at 1:09 PM, javed khan  wrote:

> Hello Lorenz yes it did not work for me. İ have about sixteen similar types
> of rules and not sure if İ need a separate SPARQL Construct query for each
> rule.
> For example another such type of rule is if a person experience is more
> than some value, then person is Experience employee and other rules like
> that.
>
> On Mon, Sep 11, 2017 at 11:18 AM, Lorenz Buehmann <
> buehm...@informatik.uni-leipzig.de> wrote:
>
> > I thought Dave explained this already. Of course you can use a SPARQL
> > CONSTRUCT query to get the same result as a single Jena rule.
> >
> > The answer is, yes. Your query should do the same as your rule.
> >
> > And I'm wondering why you can't try it out on your data? Does something
> > not work as expected?
> >
> >
> > On 10.09.2017 22:15, javed khan wrote:
> > > I am wondering if the following Construct query could lead to the
> > alternate
> > > result of the Jena rule (given below)?
> > >
> > > Rule: (?x rdf:type :Student) + (?x exp:NoOfPublications ?No)
> +greaterThan
> > > (?No, 10)-> (?x rdf:type :Researcher)
> > >
> > > Construct Query:
> > >
> > > Construct {?x rdf:type :Researcher}
> > >
> > > Where{ ?x rdf:type :Student . ?x exp: NoOfPublications ?No . Filter
> > > (?No>10) }
> > >
> >
> >
>


  1   2   3   4   5   >