How do you determine whether a triple from a query result has been inferred?

2021-12-05 Thread Simon Gray
I would like to display inferred triples differently in my UI, but I’m unsure 
how to programmatically ascertain which triple is from inference and which is 
raw data. The only way I can think of that might work would be to make a 
secondary look-up in the raw data graph and compare the difference of the 
result sets, but I thought maybe there is a utility method or some kind of 
attached metadata I could use on the individual triple instead.

Re: Re: OWL inferences in Apache Jena (for e.g. owl:allValuesFrom)

2021-12-05 Thread Lorenz Buehmann

 @Steve

Which reasoner are you using?  Have you tried openllet (Pellet for 
Jena) to see if you get the desired result?

works only with Jena 3.X

Which reasoner are you using?  Have you tried openllet (Pellet for 
Jena) to see if you get the desired result?
that look like a mix of Manchester OWL syntax and DL syntax. At least 
it's no standard notation



@Luis

On 06.12.21 06:25, Luis Enrique Ramos García wrote:


The point here, and hope to be corrected by anybody else if I am wrong, is
that you are using sparql, which is rdf based. Then, you can only query

asserted, not inferred knowledge.
In Jena you can run SPARQL queries on a model that is backed by some 
inference mechanism.


Some engines like blazegraph, let you add owl reasoning, and then you can
use the transitive feature of owl  (comment only as example).

I do not know whether or not fuseki can be configured in such a way.


The TE is already using a reasoner. But expressivity depends on the 
reasoner. For full OWL DL reasoning the only Jena compatible reasoner is 
Pellet, but the original code is only on Jena 2.X and the Openllet fork 
is Jena 3.X -


But, and now we come to the example. The Jena docs say that

The critical constructs which go beyond OWL/lite and are not supported 
in the Jena OWL reasoner are complementOf and oneOf.


the lack of support for  "oneOf" class expression (the {cat_1} is such a 
thing) which in fact means the inference is not supported by Jena 
built-in reasoners.


You can try with Jena 3.X + Openllet. Or you fork Openllet and bump to 
Jena 4.X, but I guess this needs some migration of code then.





Luis Ramos


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


Hi,
I have an OWL ontology
https://github.com/kubajal/covidepid/blob/main/minimal_test.ttl.
The ontology has the following definitions:


- Person
   - CatPerson (subClassOf Person + CatPerson equivalentTo hasPet only
   Cat)
- Animal
   - Cat (subClassOf Animal)
- hasPet: Person -> Animal

and the following instances:
- person_1: Person and (hasPet only {cat_1})
- cat_1: Cat
- hasPet(person_1, cat_1)

I am using Apache Jena Fuseki 4.2.0 with the OWLFBRuleReasoner reasoner

(link to the configuration:
https://github.com/kubajal/covidepid/blob/main/minimal_test_config.ttl).

I am executing the following query in Fuseki:


PREFIX rdf: 
PREFIX myOnt: <


http://www.semanticweb.org/kubajal/ontologies/2021/11/untitled-ontology-157/
SELECT ?s {

?s rdf:type myOnt:CatPerson .
}


No results are returned whereas I would expect person_1 to be returned (as
it is the case in e.g. Protege using Pellet).
I am using

https://jena.apache.org/documentation/ontology/#more-complex-class-expressions
as documentation which says that the "all values from" construct is
supported  (so e.g. "CatPerson equivalentTo hasPet only Cat" should work).
Am I missing something?

Best regards,
Jakub



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
> > )
> > > ) -
> > 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: OWL inferences in Apache Jena (for e.g. owl:allValuesFrom)

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

If I properly understand your notation, you are try to obtain an instance
as an inferred class.

In this case is CatPerson, a person who only has a pet of kind cat.

And, as I see you defined person_1, and you say he has a cat, then you
expect the system to infer he is a cat person, and return person_1 to you.

The point here, and hope to be corrected by anybody else if I am wrong, is
that you are using sparql, which is rdf based. Then, you can only query

asserted, not inferred knowledge.

Some engines like blazegraph, let you add owl reasoning, and then you can
use the transitive feature of owl  (comment only as example).

I do not know whether or not fuseki can be configured in such a way.


Luis Ramos


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

> Hi,
> I have an OWL ontology
> https://github.com/kubajal/covidepid/blob/main/minimal_test.ttl.
> The ontology has the following definitions:
>
> >
> >- Person
> >   - CatPerson (subClassOf Person + CatPerson equivalentTo hasPet only
> >   Cat)
> >- Animal
> >   - Cat (subClassOf Animal)
> >- hasPet: Person -> Animal
> >
> > and the following instances:
>
> >
> >- person_1: Person and (hasPet only {cat_1})
> >- cat_1: Cat
> >- hasPet(person_1, cat_1)
> >
> > I am using Apache Jena Fuseki 4.2.0 with the OWLFBRuleReasoner reasoner
> (link to the configuration:
> https://github.com/kubajal/covidepid/blob/main/minimal_test_config.ttl).
>
> I am executing the following query in Fuseki:
>
> > PREFIX rdf: 
> > PREFIX myOnt: <
> >
> http://www.semanticweb.org/kubajal/ontologies/2021/11/untitled-ontology-157/
> > >
>
> SELECT ?s {
> > ?s rdf:type myOnt:CatPerson .
> > }
>
>
> No results are returned whereas I would expect person_1 to be returned (as
> it is the case in e.g. Protege using Pellet).
> I am using
>
> https://jena.apache.org/documentation/ontology/#more-complex-class-expressions
> as documentation which says that the "all values from" construct is
> supported  (so e.g. "CatPerson equivalentTo hasPet only Cat" should work).
> Am I missing something?
>
> Best regards,
> Jakub
>


Re: OWL inferences in Apache Jena (for e.g. owl:allValuesFrom)

2021-12-05 Thread Steve Vestal
Which reasoner are you using?  Have you tried openllet (Pellet for Jena) 
to see if you get the desired result?


Out of curiosity, what notation (ontology syntax) are you using here?

On 12/5/2021 8:38 AM, Jakub Jałowiec wrote:

Hi,
I have an OWL ontology
https://github.com/kubajal/covidepid/blob/main/minimal_test.ttl.
The ontology has the following definitions:


- Person
   - CatPerson (subClassOf Person + CatPerson equivalentTo hasPet only
   Cat)
- Animal
   - Cat (subClassOf Animal)
- hasPet: Person -> Animal

and the following instances:
- person_1: Person and (hasPet only {cat_1})
- cat_1: Cat
- hasPet(person_1, cat_1)

I am using Apache Jena Fuseki 4.2.0 with the OWLFBRuleReasoner reasoner

(link to the configuration:
https://github.com/kubajal/covidepid/blob/main/minimal_test_config.ttl).

I am executing the following query in Fuseki:


PREFIX rdf: 
PREFIX myOnt: <
http://www.semanticweb.org/kubajal/ontologies/2021/11/untitled-ontology-157/

SELECT ?s {

?s rdf:type myOnt:CatPerson .
}


No results are returned whereas I would expect person_1 to be returned (as
it is the case in e.g. Protege using Pellet).
I am using
https://jena.apache.org/documentation/ontology/#more-complex-class-expressions
as documentation which says that the "all values from" construct is
supported  (so e.g. "CatPerson equivalentTo hasPet only Cat" should work).
Am I missing something?

Best regards,
Jakub



OpenPGP_signature
Description: OpenPGP digital signature


Re: Error initializing geosparql

2021-12-05 Thread Jean-Marc Vanel
I fixed the WKT not having the right datatype, as said before; here are the
SPARQL used to check and fix:
COUNT-spatial-wkt-as-string.rq

FIX-spatial-wkt-as-string.upd.rq


Now this is not the end of the road . Another imperfect data causing
geosparql initialization to fail :

*Exception: Build WKT Geometry Exception - Type: point, Coordinates:
(2.353821,48.83399,0). Index 1 out of bounds for length 1*
2021-12-05T15:48:54.166Z [application-akka.actor.default-dispatcher-5]
ERROR jena - Exception class:class
org.apache.jena.datatypes.DatatypeFormatException
2021-12-05T15:48:54.167Z [application-akka.actor.default-dispatcher-5]
ERROR jena - Exception
org.apache.jena.datatypes.DatatypeFormatException: Build WKT Geometry
Exception - Type: point, Coordinates: (2.353821,48.83399,0). Index 1 out of
bounds for length 1
org.apache.jena.geosparql.implementation.parsers.wkt.WKTReader.buildGeometry(WKTReader.java:141)
org.apache.jena.geosparql.implementation.parsers.wkt.WKTReader.(WKTReader.java:50)
org.apache.jena.geosparql.implementation.parsers.wkt.WKTReader.extract(WKTReader.java:292)

org.apache.jena.geosparql.implementation.datatype.WKTDatatype.read(WKTDatatype.java:89)
org.apache.jena.geosparql.implementation.index.GeometryLiteralIndex.retrieveMemoryIndex(GeometryLiteralIndex.java:69)
org.apache.jena.geosparql.implementation.index.GeometryLiteralIndex.retrieve(GeometryLiteralIndex.java:51)
org.apache.jena.geosparql.implementation.datatype.GeometryDatatype.parse(GeometryDatatype.java:57)
org.apache.jena.geosparql.implementation.GeometryWrapper.extract(GeometryWrapper.java:1176)

org.apache.jena.geosparql.implementation.GeometryWrapper.extract(GeometryWrapper.java:1137)
org.apache.jena.geosparql.implementation.GeometryWrapper.extract(GeometryWrapper.java:1147)
org.apache.jena.geosparql.configuration.ModeSRS.search(ModeSRS.java:61)
org.apache.jena.geosparql.configuration.GeoSPARQLOperations.findModeSRS(GeoSPARQLOperations.java:520)

Is it because the WKT separator should be a space instead of a comma, or
because 3D is not allowed ?

Jean-Marc Vanel

+33
(0)6 89 16 29 52


Le dim. 5 déc. 2021 à 13:03, Jean-Marc Vanel  a
écrit :

> After looking at this code, failing line in bold:
>
> jena-geosparql/src/main/java/org/apache/jena/geosparql/configuration/ModeSRS.java
>
> https://github.com/apache/jena/blob/main/jena-geosparql/src/main/java/org/apache/jena/geosparql/configuration/ModeSRS.java
>
> ExtendedIterator nodeIter =
> model.listObjectsOfProperty(Geo.HAS_SERIALIZATION_PROP);
> boolean isGeometryLiteralsFound = nodeIter.hasNext();
> if (!isGeometryLiteralsFound) {
> NodeIterator wktNodeIter =
> model.listObjectsOfProperty(Geo.AS_WKT_PROP);
> NodeIterator gmlNodeIter =
> model.listObjectsOfProperty(Geo.AS_GML_PROP);
> nodeIter = wktNodeIter.andThen(gmlNodeIter);
> }
>
> while (nodeIter.hasNext()) {
> RDFNode node = nodeIter.next();
> if (node.isLiteral()) {
> *GeometryWrapper geometryWrapper =
> GeometryWrapper.extract(node.asLiteral());*
>
> I did SELECT queries to try to understand what is wrong .
> It appears that these triples are not present:
> ?S  ?O .
> ?S  ?O .
>
> BUT, there is a bunch of these triples:
> ?S  ?O .
>
> Here is one example of the object values:
> "POINT(-4.189911,54.880557,0)"
> I probably imported them by hacking a JSON API as JSON-LD , I have to
> check my journals ...
>
> Looking at the OGC GeoSPARQL standard, I saw that the WKT strings should
> have this datatype :
> http://www.opengis.net/ont/geosparql#wktLiteral
>
> So I can make a SPARQL update to FIX my data .
> But maybe Jena GeoSPARQL could be forgiving about the string datatype for
> WKT data .
> And the error message should be more explicit ...
>
> Thanks Andy for the quick answer.
>
> Jean-Marc Vanel
> 
>  +33
> (0)6 89 16 29 52
>
>
> Le dim. 5 déc. 2021 à 11:52, Jean-Marc Vanel  a
> écrit :
>
>> After having fixed bad data in the TDB database (latitude is present but
>> not longitude, coordinates as strings , see issue
>> https://issues.apache.org/jira/browse/JENA-2202 ),
>> there is an exception, probably related to the database content.
>> Here is the log:
>> Dec 05, 2021 9:57:33 AM
>> org.apache.sis.referencing.factory.sql.EPSGFactory 
>> WARNING: The “SIS_DATA” environment variable is not set.
>> 2021-12-05T09:57:33.940Z [application-akka.actor.default-dispatcher-9]
>> INFO  jena - SpatialIndex: 

OWL inferences in Apache Jena (for e.g. owl:allValuesFrom)

2021-12-05 Thread Jakub Jałowiec
Hi,
I have an OWL ontology
https://github.com/kubajal/covidepid/blob/main/minimal_test.ttl.
The ontology has the following definitions:

>
>- Person
>   - CatPerson (subClassOf Person + CatPerson equivalentTo hasPet only
>   Cat)
>- Animal
>   - Cat (subClassOf Animal)
>- hasPet: Person -> Animal
>
> and the following instances:

>
>- person_1: Person and (hasPet only {cat_1})
>- cat_1: Cat
>- hasPet(person_1, cat_1)
>
> I am using Apache Jena Fuseki 4.2.0 with the OWLFBRuleReasoner reasoner
(link to the configuration:
https://github.com/kubajal/covidepid/blob/main/minimal_test_config.ttl).

I am executing the following query in Fuseki:

> PREFIX rdf: 
> PREFIX myOnt: <
> http://www.semanticweb.org/kubajal/ontologies/2021/11/untitled-ontology-157/
> >

SELECT ?s {
> ?s rdf:type myOnt:CatPerson .
> }


No results are returned whereas I would expect person_1 to be returned (as
it is the case in e.g. Protege using Pellet).
I am using
https://jena.apache.org/documentation/ontology/#more-complex-class-expressions
as documentation which says that the "all values from" construct is
supported  (so e.g. "CatPerson equivalentTo hasPet only Cat" should work).
Am I missing something?

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: 

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
> > )
> > > ) -
> > 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
> )
> > ) -
> 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: Error initializing geosparql

2021-12-05 Thread Jean-Marc Vanel
After looking at this code, failing line in bold:
jena-geosparql/src/main/java/org/apache/jena/geosparql/configuration/ModeSRS.java
https://github.com/apache/jena/blob/main/jena-geosparql/src/main/java/org/apache/jena/geosparql/configuration/ModeSRS.java

ExtendedIterator nodeIter =
model.listObjectsOfProperty(Geo.HAS_SERIALIZATION_PROP);
boolean isGeometryLiteralsFound = nodeIter.hasNext();
if (!isGeometryLiteralsFound) {
NodeIterator wktNodeIter =
model.listObjectsOfProperty(Geo.AS_WKT_PROP);
NodeIterator gmlNodeIter =
model.listObjectsOfProperty(Geo.AS_GML_PROP);
nodeIter = wktNodeIter.andThen(gmlNodeIter);
}

while (nodeIter.hasNext()) {
RDFNode node = nodeIter.next();
if (node.isLiteral()) {
*GeometryWrapper geometryWrapper =
GeometryWrapper.extract(node.asLiteral());*

I did SELECT queries to try to understand what is wrong .
It appears that these triples are not present:
?S  ?O .
?S  ?O .

BUT, there is a bunch of these triples:
?S  ?O .

Here is one example of the object values:
"POINT(-4.189911,54.880557,0)"
I probably imported them by hacking a JSON API as JSON-LD , I have to check
my journals ...

Looking at the OGC GeoSPARQL standard, I saw that the WKT strings should
have this datatype :
http://www.opengis.net/ont/geosparql#wktLiteral

So I can make a SPARQL update to FIX my data .
But maybe Jena GeoSPARQL could be forgiving about the string datatype for
WKT data .
And the error message should be more explicit ...

Thanks Andy for the quick answer.

Jean-Marc Vanel

+33
(0)6 89 16 29 52


Le dim. 5 déc. 2021 à 11:52, Jean-Marc Vanel  a
écrit :

> After having fixed bad data in the TDB database (latitude is present but
> not longitude, coordinates as strings , see issue
> https://issues.apache.org/jira/browse/JENA-2202 ),
> there is an exception, probably related to the database content.
> Here is the log:
> Dec 05, 2021 9:57:33 AM org.apache.sis.referencing.factory.sql.EPSGFactory
> 
> WARNING: The “SIS_DATA” environment variable is not set.
> 2021-12-05T09:57:33.940Z [application-akka.actor.default-dispatcher-9]
> INFO  jena - SpatialIndex: isFunctionRegistered true
> 2021-12-05T09:57:33.941Z [application-akka.actor.default-dispatcher-9]
> INFO  jena - Before setupSpatialIndex
> 2021-12-05T09:57:33.948Z [application-akka.actor.default-dispatcher-9]
> INFO  o.a.j.g.c.GeoSPARQLOperations - Find Mode SRS - Started
>
> And here is the exception:
> *Exception: Unrecognised Geometry Datatype:
> http://www.w3.org/2001/XMLSchema#string
>  Ensure that Datatype is extending
> GeometryDatatype.*
>
> org.apache.jena.geosparql.implementation.datatype.GeometryDatatype.get(GeometryDatatype.java:78)
>
> org.apache.jena.geosparql.implementation.datatype.GeometryDatatype.get(GeometryDatatype.java:86)
>
> org.apache.jena.geosparql.implementation.GeometryWrapper.extract(GeometryWrapper.java:1175)
>
> org.apache.jena.geosparql.implementation.GeometryWrapper.extract(GeometryWrapper.java:1137)
>
> org.apache.jena.geosparql.implementation.GeometryWrapper.extract(GeometryWrapper.java:1147)
> org.apache.jena.geosparql.configuration.ModeSRS.search(ModeSRS.java:61)
>
> org.apache.jena.geosparql.configuration.GeoSPARQLOperations.findModeSRS(GeoSPARQLOperations.java:520)
>
> org.apache.jena.geosparql.spatial.SpatialIndex.buildSpatialIndex(SpatialIndex.java:336)
>
> org.apache.jena.geosparql.configuration.GeoSPARQLConfig.setupSpatialIndex(GeoSPARQLConfig.java:263)
>
> deductions.runtime.jena.RDFStoreLocalJenaProviderObject$.createDatabase(RDFStoreLocalJenaProvider.scala:175)
>
> I use the latest Jena release 4.2.0 . Note that there is no trouble on my
> development machine, only on the production site , although the source is
> the same .
>
> Jean-Marc Vanel
>
>


Re: Error initializing geosparql

2021-12-05 Thread Andy Seaborne




On 05/12/2021 10:52, Jean-Marc Vanel wrote:

After having fixed bad data in the TDB database (latitude is present but
not longitude, coordinates as strings , see issue
https://issues.apache.org/jira/browse/JENA-2202 ),
there is an exception, probably related to the database content.
Here is the log:
Dec 05, 2021 9:57:33 AM org.apache.sis.referencing.factory.sql.EPSGFactory

WARNING: The “SIS_DATA” environment variable is not set.
2021-12-05T09:57:33.940Z [application-akka.actor.default-dispatcher-9] INFO
  jena - SpatialIndex: isFunctionRegistered true
2021-12-05T09:57:33.941Z [application-akka.actor.default-dispatcher-9] INFO
  jena - Before setupSpatialIndex
2021-12-05T09:57:33.948Z [application-akka.actor.default-dispatcher-9] INFO
  o.a.j.g.c.GeoSPARQLOperations - Find Mode SRS - Started

And here is the exception:
*Exception: Unrecognised Geometry Datatype:
http://www.w3.org/2001/XMLSchema#string
 Ensure that Datatype is extending
GeometryDatatype.*
org.apache.jena.geosparql.implementation.datatype.GeometryDatatype.get(GeometryDatatype.java:78)


(rdfDatatype instanceof GeometryDatatype)

so maybe rdfDatatype is null.


org.apache.jena.geosparql.implementation.datatype.GeometryDatatype.get(GeometryDatatype.java:86)


which would happen if datatypeURI not in the map.


org.apache.jena.geosparql.implementation.GeometryWrapper.extract(GeometryWrapper.java:1175)
org.apache.jena.geosparql.implementation.GeometryWrapper.extract(GeometryWrapper.java:1137)
org.apache.jena.geosparql.implementation.GeometryWrapper.extract(GeometryWrapper.java:1147)
org.apache.jena.geosparql.configuration.ModeSRS.search(ModeSRS.java:61)
org.apache.jena.geosparql.configuration.GeoSPARQLOperations.findModeSRS(GeoSPARQLOperations.java:520)
org.apache.jena.geosparql.spatial.SpatialIndex.buildSpatialIndex(SpatialIndex.java:336)
org.apache.jena.geosparql.configuration.GeoSPARQLConfig.setupSpatialIndex(GeoSPARQLConfig.java:263)
deductions.runtime.jena.RDFStoreLocalJenaProviderObject$.createDatabase(RDFStoreLocalJenaProvider.scala:175)

I use the latest Jena release 4.2.0 . Note that there is no trouble on my
development machine, only on the production site , although the source is
the same .


If it is a data issue, we need a producible example (java, or 
data+query), to see further what is happening.


Also, please try the current development version of 4.3.0-SANSHOT which 
has the JENA-2220 fix in it.


Andy



Jean-Marc Vanel



Error initializing geosparql

2021-12-05 Thread Jean-Marc Vanel
After having fixed bad data in the TDB database (latitude is present but
not longitude, coordinates as strings , see issue
https://issues.apache.org/jira/browse/JENA-2202 ),
there is an exception, probably related to the database content.
Here is the log:
Dec 05, 2021 9:57:33 AM org.apache.sis.referencing.factory.sql.EPSGFactory

WARNING: The “SIS_DATA” environment variable is not set.
2021-12-05T09:57:33.940Z [application-akka.actor.default-dispatcher-9] INFO
 jena - SpatialIndex: isFunctionRegistered true
2021-12-05T09:57:33.941Z [application-akka.actor.default-dispatcher-9] INFO
 jena - Before setupSpatialIndex
2021-12-05T09:57:33.948Z [application-akka.actor.default-dispatcher-9] INFO
 o.a.j.g.c.GeoSPARQLOperations - Find Mode SRS - Started

And here is the exception:
*Exception: Unrecognised Geometry Datatype:
http://www.w3.org/2001/XMLSchema#string
 Ensure that Datatype is extending
GeometryDatatype.*
org.apache.jena.geosparql.implementation.datatype.GeometryDatatype.get(GeometryDatatype.java:78)
org.apache.jena.geosparql.implementation.datatype.GeometryDatatype.get(GeometryDatatype.java:86)
org.apache.jena.geosparql.implementation.GeometryWrapper.extract(GeometryWrapper.java:1175)
org.apache.jena.geosparql.implementation.GeometryWrapper.extract(GeometryWrapper.java:1137)
org.apache.jena.geosparql.implementation.GeometryWrapper.extract(GeometryWrapper.java:1147)
org.apache.jena.geosparql.configuration.ModeSRS.search(ModeSRS.java:61)
org.apache.jena.geosparql.configuration.GeoSPARQLOperations.findModeSRS(GeoSPARQLOperations.java:520)
org.apache.jena.geosparql.spatial.SpatialIndex.buildSpatialIndex(SpatialIndex.java:336)
org.apache.jena.geosparql.configuration.GeoSPARQLConfig.setupSpatialIndex(GeoSPARQLConfig.java:263)
deductions.runtime.jena.RDFStoreLocalJenaProviderObject$.createDatabase(RDFStoreLocalJenaProvider.scala:175)

I use the latest Jena release 4.2.0 . Note that there is no trouble on my
development machine, only on the production site , although the source is
the same .

Jean-Marc Vanel


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)
) - 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