RE: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror

2016-11-01 Thread omar.khan
Hi Andy - further info from Ramesh ; thanks for your patience  - he was having 
access accessing /reading MarkMail - so I'm relaying (original from bottom of 
https://developer.jboss.org/thread/272656) :

"Basically what they need to do, replace their ServiceLoader mechanism with 
standard JDBC4 ServiceLoader mechanism like 
https://github.com/rareddy/teiid/tree/master/client/src/main/resources/META-INF/services
 That will register their Driver class, and in their driver class possibly in a 
"static block" call ARQ.init() that will initialize every time one uses their 
JDBC driver. "
 
-Original Message-
From: Andy Seaborne [mailto:a...@apache.org] 
Sent: Tuesday, November 01, 2016 12:10 PM
To: users@jena.apache.org
Subject: Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror



On 01/11/16 14:54, omar.k...@wellsfargo.com wrote:
> Thanks Andy!
>
> Question - who is responsible for loading the JDBC driver, and how does one 
> load it?
>
> I'm not clear on exact details on how to get it to work. I reached out to the 
> Teiid team, and Ramesh has a question for you .
>
> Can you look at the bottom of this thread for the question from Ramesh?
>
> https://developer.jboss.org/thread/272656

Firstly - I didn't write and don't use jena-jdbc so my level of expertise is 
limited.  The initialization of Jena in shaded jars is something that has come 
up before.

It looks like the problem is at the Jena initialization step, not the loading 
the JDBC driver. That's supposed to be automatic and is - the crash happens 
because the initialization is incomplete or is happening in the wrong order 
because the normal sequence isn't happening.

In yoru code, if you can, call ARQ.init() before anything else.  Calling it 
repeatedly is safe and cheap.

Hopefully RobV can give a better answer for the JDBC aspects.

There is a services/java.sql.Driver - that should cause the JDBC driver to 
load.  Standard way for Java.

Andy


>
>
> -Original Message-
> From: Andy Seaborne [mailto:a...@apache.org]
> Sent: Tuesday, November 01, 2016 5:49 AM
> To: users@jena.apache.org
> Subject: Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror
>
>
>> I checked and the jena-jdbc-driver-bundle does not set up the 
>> ServiceLoader services correctly.  We'll fix that.
>
> jena-jdbc-driver-bundle should be fixed (JENA-1255) now. There is a 
> development with it in.
>
>  Andy
>
>>
>> But I don't immediately see why using the jars directly does not 
>> work, but that's due to my lack of knowledge about Teiid and JBoss.
>>
>> Is there any repackaging going on?
>>
>> Andy
>


Re: Handling named graphs in Jena.

2016-11-01 Thread Martynas Jusevičius
1. You haven't followed the example. You are missing Syntax.syntaxARQ
in QueryFactory.create(), I guess this makes a difference since
CONSTRUCT with quads is not standard SPARQL.

2. Because INSERT is an update and not a query? Se UpdateFactory:
https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/update/UpdateFactory.html

On Wed, Nov 2, 2016 at 1:30 AM, Jason Koh  wrote:
>  Dear all,
>
> This might be due to my lack of knowledge on SPARQL syntax.
>
> 1.
> I try to construct a named graph via SPARQL query, but it fails.
> so What I did is like following
> ///
> Model model = ModelFactory.createDefaultModel();
> String queryStr ="CONSTRUCT {GRAPH  {  .} }
> WHERE{}";
> Query query = QueryFactory.create(queryStr);
> QueryExecution qe = QueryExecutionFactory.create(query,  resultModel);
> /
>
> It fails at the third line while it is parsing with this error message:
> Exception in thread "main" org.apache.jena.query.QueryParseException:
> Encountered " "graph" "GRAPH "" at line 1, column 335.
>
> I am thinking that I am following
> https://jena.apache.org/documentation/query/construct-quad.html correctly.
>
> Could you tell me the problem in the query?
>
>
> 2.
> Actually I rather want to use INSERT instead of CONSTRUCT, but QueryFactory
> cannot parse INSERT. Why is that?
>
> Thanks!
>
>
> With regards,
> Jason Koh
> cseweb.ucsd.edu/~jbkoh


Handling named graphs in Jena.

2016-11-01 Thread Jason Koh
 Dear all,

This might be due to my lack of knowledge on SPARQL syntax.

1.
I try to construct a named graph via SPARQL query, but it fails.
so What I did is like following
///
Model model = ModelFactory.createDefaultModel();
String queryStr ="CONSTRUCT {GRAPH  {  .} }
WHERE{}";
Query query = QueryFactory.create(queryStr);
QueryExecution qe = QueryExecutionFactory.create(query,  resultModel);
/

It fails at the third line while it is parsing with this error message:
Exception in thread "main" org.apache.jena.query.QueryParseException:
Encountered " "graph" "GRAPH "" at line 1, column 335.

I am thinking that I am following
https://jena.apache.org/documentation/query/construct-quad.html correctly.

Could you tell me the problem in the query?


2.
Actually I rather want to use INSERT instead of CONSTRUCT, but QueryFactory
cannot parse INSERT. Why is that?

Thanks!


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


Re: Placement of VALUES block affects performance in 3.1.1

2016-11-01 Thread james anderson
good evening;

> On 2016-11-01, at 20:12, Andy Seaborne  wrote:
> 
> 
> 
> On 01/11/16 12:38, Osma Suominen wrote:
>> Hi,
>> [about a query which exercises the interaction between a values clause and 
>> statement pattern at locations relatively remote in the query. ]
> 
> [ the question leads to a point about the scope of the respective ?uri 
> variables, ]
> 
> The issue is [*], using the variable ?uri again inside an OPTIONAL.
> 
> It is possible that ?uri will range over more than the VALUES setting and 
> affect the OPTIONAL yet the inner EXISTS usage does not set ?uri and it is 
> not propagated to be joined with the set value.
> 
> […]
> 
> [ … and to one about algebraic equivalence among expressions and the 
> consequent latitude to relocate the values clause.]
> 
> It can be pushed in because:
> 
> join(A, union(B,C)) == union(join(A,B), join(A,C))
> 
> now if A is an complex expression, that is a bad idea (probably).
> 
> If A is a small VALUES block then it makes sense.  It isn't done though.
> 

both of which are significant, but remain side matters to the principal issue, 
which concerns a reasonable expectation - despite that it may be subject to 
revision, that the values clause introduces bindings with indefinite scope.[1]

as sparql plays in increasingly significant role in service implementations, 
library-level support for query parameters[2] needs to give way to 
protocol-level mechanisms,[3] whereby the language semantics needs more 
attention than it has yet received.
both immediately federated request combinations and request chains which are 
mediated by a third service need to  propagate intermediate solution sets 
across requests. 
the use case behind this question is one example.

the implementations for elementary variables[3] do not provide sufficient 
capacity - not to mention the deficiencies of their substitution models.
the sparql federated query recommendation suggests a role which the values 
clause might play,[4] but does not provide an exact interpretation.

has jena’s community given this topic any thought?

best regards, from berlin,
- - -
[1] : 
http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node43.html#SECTION0070
[2] : 
https://jena.apache.org/documentation/query/parameterized-sparql-strings.html
[3] : http://docs.rdf4j.org/rest-api/#_repository_queries
[4] : http://www.w3.org/TR/sparql11-federated-query/#values


---
james anderson | ja...@dydra.com | http://dydra.com







Filter syntax

2016-11-01 Thread kumar rohit
  + "FILTER ( ?student =' "+name+" ' ) " //name can be any string

   + "FILTER ( ?student , ' "+name+" ' ) "

which syntax is correct? == sign or just comma sign?
And is regex keyword mandatory here? In which situation we should use regex
with Filter keyword?


Re: Use variable in SPARQL query

2016-11-01 Thread Claude Warren
You can do the substitution quite easily using the querybuilder package.
It will let you build a query like

?emp rdf:type ?empType

and then bind ?empType to your java variable value.

Claude

On Tue, Nov 1, 2016 at 5:21 PM, Andy Seaborne  wrote:

> Try and see what happens.
>
> It won't work but you can the see the results SPARQL syntax error.
>
> Andy
>
>
> On 01/11/16 16:54, tina sani wrote:
>
>> Will simply putting a variable inside a query work?
>>
>> {?emp rdf:type "+employee+"}";
>>
>> On Tue, Nov 1, 2016 at 6:13 PM, lookman sanni 
>> wrote:
>>
>> Hi Tina,
>>>
>>> You can have your query stored in a composed java string (e.g. String
>>> query
>>> = "Select blablabla where { ?emp rdf:type " + someJavaVariable + "}"
>>>
>>> Hope that helps
>>> Le 1 nov. 2016 17:02, "tina sani"  a écrit :
>>>
>>> Hello.

 How can I use a Java variable in the SPARQL query.
 ?emp rdf:type ?SomeVariable

 I want rdf:type of Managers and Technicals while these two

>>> values(Managers
>>>
 and Technicals) are in my Java variable: employee.

 So I need something like:

 ?emp rdf:type "employee"

 Regards


>>>
>>


-- 
I like: Like Like - The likeliest place on the web

LinkedIn: http://www.linkedin.com/in/claudewarren


Re: Placement of VALUES block affects performance in 3.1.1

2016-11-01 Thread Andy Seaborne



On 01/11/16 12:38, Osma Suominen wrote:

Hi,

Some further observations. The query I sent earlier was a minimal
example, and it was possible to fix it by just moving the VALUES block.
But a slightly more realistic (closer to the original query I'm having
problems with) example involves a UNION and cannot be fixed so easily -
placing the VALUES block first doesn't help:

--cut--
PREFIX skos: 
SELECT *
WHERE {
  VALUES ?uri {  }
  { ?s ?p ?uri }
  UNION
  { ?uri ?p ?o
  OPTIONAL {
?x skos:member ?o .
FILTER NOT EXISTS {
  ?x skos:member ?other .
  FILTER NOT EXISTS {
?other skos:broader ?uri

 ^^ [*]

  }
}
  } }
}
--cut--

Jena 3.1.0 tdbquery: 0.9 seconds
Jena 3.1.1-SNAPSHOT tdbquery: 12.8 seconds

I'm aware that in SPARQL, evaluation proceeds from the inside out and
Jena ARQ has moved more and more in this direction with recent releases,
which may also explain this change.


It has always been inside-out then optimized to use stream based index 
joins.


However in this case "inside out" is confusing because the query has a 
double negation of FILTER NOT EXIST.


At 3.1.1 (JENA-1171), EXISTS are analysed whereas previous they were 
skipped which could lead to wrong answers.


Osma - could you please try putting the VALUES in each arm of the UNION 
which gets you to something like the first example.



The issue is [*], using the variable ?uri again inside an OPTIONAL.

It is possible that ?uri will range over more than the VALUES setting 
and affect the OPTIONAL yet the inner EXISTS usage does not set ?uri and 
it is not propagated to be joined with the set value.


As wikipedia says for correlated subquery in SQL:
"Because the subquery is evaluated once for each row processed by the 
outer query, it can be inefficient."



But how should VALUES blocks be
placed for optimal query execution? It seems like a waste not to
propagate those fixed bindings into inner parts of the query, even
though that may violate the inside-out order.


It can be pushed in because:

join(A, union(B,C)) == union(join(A,B), join(A,C))

now if A is an complex expression, that is a bad idea (probably).

If A is a small VALUES block then it makes sense.  It isn't done though.

> In the above query, I

don't know where to place the VALUES so that the binding for ?uri (in
effect, changing the variable to a constant) would be applied in all
parts of the query.


See above.



Placing the VALUES block at the bottom of the query (outside the WHERE
block) doesn't help either. In fact execution time increases to 17
seconds with 3.1.1-SNAPSHOT (but is unchanged with 3.1.0).

I tried --engine=ref and it was extremely slow also with 3.1.0, so in
that sense, nothing has changed, only an optimization has been dropped
somewhere.

Should I report this as an issue? Or am I just doing something wrong?

-Osma



On 01/11/16 11:03, Osma Suominen wrote:

Hi,

I'm investigating a performance regression we're seeing with the current
Jena 3.1.1-SNAPSHOT compared to 3.1.0.

The data in graph  is the YSO ontology,
available from http://api.finto.fi/download/yso/yso-skos.ttl

This query used to take about 0.2 seconds (with 3.1.0) and now takes
about 10 seconds:

--cut--
PREFIX skos: 
SELECT *
FROM NAMED 
WHERE {
   ?uri ?p ?o .
   OPTIONAL {
 ?x skos:member ?o .
 FILTER NOT EXISTS {
   ?x skos:member ?other .
   FILTER NOT EXISTS {
 ?other skos:broader ?uri
   }
 }
   }
   VALUES ?uri {  }
}
--cut--

If I move the VALUES block to the top of the query, right after WHERE,
then the query becomes fast again.

Is the placement of the VALUES block supposed to affect query evaluation
order in this way? It appears to me that in the slow version, ?uri is
not bound inside the inner FILTER NOT EXISTS, which causes an explosion
of results internally.

-Osma






Re: Use variable in SPARQL query

2016-11-01 Thread Andy Seaborne

Try and see what happens.

It won't work but you can the see the results SPARQL syntax error.

Andy

On 01/11/16 16:54, tina sani wrote:

Will simply putting a variable inside a query work?

{?emp rdf:type "+employee+"}";

On Tue, Nov 1, 2016 at 6:13 PM, lookman sanni  wrote:


Hi Tina,

You can have your query stored in a composed java string (e.g. String query
= "Select blablabla where { ?emp rdf:type " + someJavaVariable + "}"

Hope that helps
Le 1 nov. 2016 17:02, "tina sani"  a écrit :


Hello.

How can I use a Java variable in the SPARQL query.
?emp rdf:type ?SomeVariable

I want rdf:type of Managers and Technicals while these two

values(Managers

and Technicals) are in my Java variable: employee.

So I need something like:

?emp rdf:type "employee"

Regards







Re: Use variable in SPARQL query

2016-11-01 Thread tina sani
Will simply putting a variable inside a query work?

{?emp rdf:type "+employee+"}";

On Tue, Nov 1, 2016 at 6:13 PM, lookman sanni  wrote:

> Hi Tina,
>
> You can have your query stored in a composed java string (e.g. String query
> = "Select blablabla where { ?emp rdf:type " + someJavaVariable + "}"
>
> Hope that helps
> Le 1 nov. 2016 17:02, "tina sani"  a écrit :
>
> > Hello.
> >
> > How can I use a Java variable in the SPARQL query.
> > ?emp rdf:type ?SomeVariable
> >
> > I want rdf:type of Managers and Technicals while these two
> values(Managers
> > and Technicals) are in my Java variable: employee.
> >
> > So I need something like:
> >
> > ?emp rdf:type "employee"
> >
> > Regards
> >
>


Re: Use variable in SPARQL query

2016-11-01 Thread Martynas Jusevičius
A safer way would be to use ParameterizedSparqlString:
https://jena.apache.org/documentation/javadoc/arq/org/apache/jena/query/ParameterizedSparqlString.html

On Tue, Nov 1, 2016 at 5:13 PM, lookman sanni  wrote:
> Hi Tina,
>
> You can have your query stored in a composed java string (e.g. String query
> = "Select blablabla where { ?emp rdf:type " + someJavaVariable + "}"
>
> Hope that helps
> Le 1 nov. 2016 17:02, "tina sani"  a écrit :
>
>> Hello.
>>
>> How can I use a Java variable in the SPARQL query.
>> ?emp rdf:type ?SomeVariable
>>
>> I want rdf:type of Managers and Technicals while these two values(Managers
>> and Technicals) are in my Java variable: employee.
>>
>> So I need something like:
>>
>> ?emp rdf:type "employee"
>>
>> Regards
>>


Re: Use variable in SPARQL query

2016-11-01 Thread lookman sanni
Hi Tina,

You can have your query stored in a composed java string (e.g. String query
= "Select blablabla where { ?emp rdf:type " + someJavaVariable + "}"

Hope that helps
Le 1 nov. 2016 17:02, "tina sani"  a écrit :

> Hello.
>
> How can I use a Java variable in the SPARQL query.
> ?emp rdf:type ?SomeVariable
>
> I want rdf:type of Managers and Technicals while these two values(Managers
> and Technicals) are in my Java variable: employee.
>
> So I need something like:
>
> ?emp rdf:type "employee"
>
> Regards
>


Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror

2016-11-01 Thread Andy Seaborne



On 01/11/16 14:54, omar.k...@wellsfargo.com wrote:

Thanks Andy!

Question - who is responsible for loading the JDBC driver, and how does one 
load it?

I'm not clear on exact details on how to get it to work. I reached out to the 
Teiid team, and Ramesh has a question for you .

Can you look at the bottom of this thread for the question from Ramesh?

https://developer.jboss.org/thread/272656


Firstly - I didn't write and don't use jena-jdbc so my level of 
expertise is limited.  The initialization of Jena in shaded jars is 
something that has come up before.


It looks like the problem is at the Jena initialization step, not the 
loading the JDBC driver. That's supposed to be automatic and is - the 
crash happens because the initialization is incomplete or is happening 
in the wrong order because the normal sequence isn't happening.


In yoru code, if you can, call ARQ.init() before anything else.  Calling 
it repeatedly is safe and cheap.


Hopefully RobV can give a better answer for the JDBC aspects.

There is a services/java.sql.Driver - that should cause the JDBC driver 
to load.  Standard way for Java.


Andy





-Original Message-
From: Andy Seaborne [mailto:a...@apache.org]
Sent: Tuesday, November 01, 2016 5:49 AM
To: users@jena.apache.org
Subject: Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror



I checked and the jena-jdbc-driver-bundle does not set up the
ServiceLoader services correctly.  We'll fix that.


jena-jdbc-driver-bundle should be fixed (JENA-1255) now. There is a development 
with it in.

 Andy



But I don't immediately see why using the jars directly does not work,
but that's due to my lack of knowledge about Teiid and JBoss.

Is there any repackaging going on?

Andy




Use variable in SPARQL query

2016-11-01 Thread tina sani
Hello.

How can I use a Java variable in the SPARQL query.
?emp rdf:type ?SomeVariable

I want rdf:type of Managers and Technicals while these two values(Managers
and Technicals) are in my Java variable: employee.

So I need something like:

?emp rdf:type "employee"

Regards


RE: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror

2016-11-01 Thread omar.khan
Thanks Andy! 

Question - who is responsible for loading the JDBC driver, and how does one 
load it? 

I'm not clear on exact details on how to get it to work. I reached out to the 
Teiid team, and Ramesh has a question for you . 

Can you look at the bottom of this thread for the question from Ramesh? 

https://developer.jboss.org/thread/272656


-Original Message-
From: Andy Seaborne [mailto:a...@apache.org] 
Sent: Tuesday, November 01, 2016 5:49 AM
To: users@jena.apache.org
Subject: Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror


> I checked and the jena-jdbc-driver-bundle does not set up the 
> ServiceLoader services correctly.  We'll fix that.

jena-jdbc-driver-bundle should be fixed (JENA-1255) now. There is a development 
with it in.

 Andy

>
> But I don't immediately see why using the jars directly does not work, 
> but that's due to my lack of knowledge about Teiid and JBoss.
>
> Is there any repackaging going on?
>
> Andy



Re: completion with Lucene: desirable from SPARQL

2016-11-01 Thread Osma Suominen

Hi Jean-Marc,

The wildcard queries etc. are basic Lucene features, part of Lucene 
query syntax, so probably that's why they not documented on the 
jena-text page. The query string is simply passed to the Lucene query 
parser by jena-text and should support any features of Lucene, see: 
http://lucene.apache.org/core/6_2_1/queryparser/org/apache/lucene/queryparser/classic/package-summary.html#package.description


Glad you were able to get your lookup service working!

Regarding the saving of weights: I think you could simply save them as 
triples (perhaps in a separate graph), outside the Lucene index. Then 
combine the results of the text:query with the weights from triples 
using SPARQL.


The jena-text query also returns score values. I'm not sure how useful 
they are in your use case, but they could potentially be used as a 
factor in the overall "notoriety" calculation. Though if you are 
searching just for single words or prefixes, chances are that the score 
values will be the same for all results.


Thanks for all the work on the Lucene 5 and 6 upgrade (JENA-1250)! I 
hope we can finish that work and get it merged soon after the 3.1.1 
release. In any case the newer Lucene version should perform better and 
be easier to maintain moving forward.


-Osma

On 01/11/16 11:01, Jean-Marc Vanel wrote:

I's too bad that the * joker feature, and other details of the SPARQL to
Lucene query translation, are not documented on the Jena text search page.

Anyway, it works for my use case, I now have on my laptop a (kind of)
replacement of dbPedia lookup service.

To experiment with the original dbPedia lookup service, you can go to
semantic_forms sandbox:
http://163.172.179.125:9111/create?uri==http%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2FPerson
and type a few letters in the dct:subject field.

I don't need the full original literal value, because the URI results of
the query are labelled in the application: a foaf:Person is labelled by
given and family names, etc.

BUT, there is a "but", the dbPedia lookup service are apropriately ordered
by "notoriety".
Instead, I currently get with http://localhost:9000/lookup?q=*Pari*
on my TDB that mirrors dbPedia.


 
   Université Pierre-et-Marie-Curie
   http://dbpedia.org/resource/Pierre_and_Marie_Curie_University

 
   Guillaume Le Gentil
   http://dbpedia.org/resource/Guillaume_Le_Gentil
 
   1 E1 m
   http://dbpedia.org/resource/1_decametre
 
   1 E4 m
   http://dbpedia.org/resource/1_myriametre
 
   Nadia Boulanger
   http://dbpedia.org/resource/Nadia_Boulanger
 
   Luis Mariano
   http://dbpedia.org/resource/Luis_Mariano
 
   Paul Chemetov
   http://dbpedia.org/resource/Paul_Chemetov
 
   Marc Boegner
   http://dbpedia.org/resource/Marc_Boegner
 
   Cassandre (graphiste)
   http://dbpedia.org/resource/Cassandre_(artist)
 
   La Norville
   http://dbpedia.org/resource/La_Norville
 
 

My understanding is that I need to set a weight on URI's in Lucene to
reflect their "notoriety".
I see 2 ways:

1. easy to implement: just count the triples from and to the URI
2. also take in account the the URI's consulted by user in my
application (but currently I don't record that information); there is
also the issue of combining weights 1) and 2)

Google search does both weightings.

So, in the short term I have to figure out how to add weights to the Lucene
- Jena index.

Then I have to read what dbPedia lookup does, and other background material.



2016-10-31 16:42 GMT+01:00 Osma Suominen :


Hi Jean-Marc,

Depending on what exactly you want from such a service, this may be
already possible with jena-text.

I'm assuming that you want to perform a prefix search such as "édu*" and
get possible completions for that, such as "éducation".

You can of course already do a prefix search with jena-text. What you will
get back will be the RDF resources which have labels that contain this
prefix. If the text index is configured to store literal values, you can
ask for the actual values as well.

E.g. with this data:

ex:cse rdfs:label "Conseil supérieur de l'éducation"@fr .

and a suitably configured jena-text index, you can perform this query:

(?s ?score ?literal) text:query (rdfs:label "édu*") .

and get back these bindings:

?s=ex:cse ?literal="Conseil supérieur de l'éducation"@fr

However, you will get the full original literal value, not just the
individual word that matched ("éducation"). If you want just the matched
word, you will need special support that jena-text doesn't currently have.

-Osma

On 17/10/16 11:37, Jean-Marc Vanel wrote:


Hi

I'm implementing an equivalent of dbPedia lookup service [1] in
semantic_forms, leveraging on Lucene integration in TDB, and dbPedia
mirror
with TDB [2] 

Re: Placement of VALUES block affects performance in 3.1.1

2016-11-01 Thread Osma Suominen

Hi,

Some further observations. The query I sent earlier was a minimal 
example, and it was possible to fix it by just moving the VALUES block. 
But a slightly more realistic (closer to the original query I'm having 
problems with) example involves a UNION and cannot be fixed so easily - 
placing the VALUES block first doesn't help:


--cut--
PREFIX skos: 
SELECT *
WHERE {
  VALUES ?uri {  }
  { ?s ?p ?uri }
  UNION
  { ?uri ?p ?o
  OPTIONAL {
?x skos:member ?o .
FILTER NOT EXISTS {
  ?x skos:member ?other .
  FILTER NOT EXISTS {
?other skos:broader ?uri
  }
}
  } }
}
--cut--

Jena 3.1.0 tdbquery: 0.9 seconds
Jena 3.1.1-SNAPSHOT tdbquery: 12.8 seconds

I'm aware that in SPARQL, evaluation proceeds from the inside out and 
Jena ARQ has moved more and more in this direction with recent releases, 
which may also explain this change. But how should VALUES blocks be 
placed for optimal query execution? It seems like a waste not to 
propagate those fixed bindings into inner parts of the query, even 
though that may violate the inside-out order. In the above query, I 
don't know where to place the VALUES so that the binding for ?uri (in 
effect, changing the variable to a constant) would be applied in all 
parts of the query.


Placing the VALUES block at the bottom of the query (outside the WHERE 
block) doesn't help either. In fact execution time increases to 17 
seconds with 3.1.1-SNAPSHOT (but is unchanged with 3.1.0).


I tried --engine=ref and it was extremely slow also with 3.1.0, so in 
that sense, nothing has changed, only an optimization has been dropped 
somewhere.


Should I report this as an issue? Or am I just doing something wrong?

-Osma



On 01/11/16 11:03, Osma Suominen wrote:

Hi,

I'm investigating a performance regression we're seeing with the current
Jena 3.1.1-SNAPSHOT compared to 3.1.0.

The data in graph  is the YSO ontology,
available from http://api.finto.fi/download/yso/yso-skos.ttl

This query used to take about 0.2 seconds (with 3.1.0) and now takes
about 10 seconds:

--cut--
PREFIX skos: 
SELECT *
FROM NAMED 
WHERE {
   ?uri ?p ?o .
   OPTIONAL {
 ?x skos:member ?o .
 FILTER NOT EXISTS {
   ?x skos:member ?other .
   FILTER NOT EXISTS {
 ?other skos:broader ?uri
   }
 }
   }
   VALUES ?uri {  }
}
--cut--

If I move the VALUES block to the top of the query, right after WHERE,
then the query becomes fast again.

Is the placement of the VALUES block supposed to affect query evaluation
order in this way? It appears to me that in the slow version, ?uri is
not bound inside the inner FILTER NOT EXISTS, which causes an explosion
of results internally.

-Osma




--
Osma Suominen
D.Sc. (Tech), Information Systems Specialist
National Library of Finland
P.O. Box 26 (Kaikukatu 4)
00014 HELSINGIN YLIOPISTO
Tel. +358 50 3199529
osma.suomi...@helsinki.fi
http://www.nationallibrary.fi


Re: External Reasoners in Jena

2016-11-01 Thread Lorenz B.
The are forks of Pellet that work with Apache Jena 3, e.g. Openllet[1]

[1] https://github.com/Galigator/openllet

> Thanks Andy and every one answered my emails, I really appreciate that.
> I know that there is no relation between Pellet and Apache Jena projects. I 
> mentioned that Pellet does not support Jena 3 not to ask for help. I am sorry 
> for including it in my email.
> Jena's documentation mentions that it supports some external reasoners. One 
> of these reasoners is Pellet and I am using it because it supports SWRL 
> rules.  
> I am asking if anyone knows how to apply SWRL rules by using Pellet reasoner 
> in Jena framework application. My example code is in the my last email. 
>
> Thanks again.
> Abdul 
>
>
>
>
>   From: Andy Seaborne 
>  To: users@jena.apache.org 
>  Sent: Monday, 31 October 2016, 10:19
>  Subject: Re: External Reasoners in Jena
>
>
>
> On 31/10/16 10:09, Abduladem Eljamel wrote:
>> Also, I wouldlike to mention that Pellet API for Jena does not support Jena 
>> 3.
> Pellet is not connected to Apache Jena. There is nothing the project 
> here can do.
>
> Andy
>
>
>

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



Re: JDBC in Teiid/JBoss NodeValue / ClassNotFounderror

2016-11-01 Thread Andy Seaborne



I checked and the jena-jdbc-driver-bundle does not set up the
ServiceLoader services correctly.  We'll fix that.


jena-jdbc-driver-bundle should be fixed (JENA-1255) now. There is a 
development with it in.


Andy



But I don't immediately see why using the jars directly does not work,
but that's due to my lack of knowledge about Teiid and JBoss.

Is there any repackaging going on?

Andy




Placement of VALUES block affects performance in 3.1.1

2016-11-01 Thread Osma Suominen

Hi,

I'm investigating a performance regression we're seeing with the current 
Jena 3.1.1-SNAPSHOT compared to 3.1.0.


The data in graph  is the YSO ontology, 
available from http://api.finto.fi/download/yso/yso-skos.ttl


This query used to take about 0.2 seconds (with 3.1.0) and now takes 
about 10 seconds:


--cut--
PREFIX skos: 
SELECT *
FROM NAMED 
WHERE {
  ?uri ?p ?o .
  OPTIONAL {
?x skos:member ?o .
FILTER NOT EXISTS {
  ?x skos:member ?other .
  FILTER NOT EXISTS {
?other skos:broader ?uri
  }
}
  }
  VALUES ?uri {  }
}
--cut--

If I move the VALUES block to the top of the query, right after WHERE, 
then the query becomes fast again.


Is the placement of the VALUES block supposed to affect query evaluation 
order in this way? It appears to me that in the slow version, ?uri is 
not bound inside the inner FILTER NOT EXISTS, which causes an explosion 
of results internally.


-Osma

--
Osma Suominen
D.Sc. (Tech), Information Systems Specialist
National Library of Finland
P.O. Box 26 (Kaikukatu 4)
00014 HELSINGIN YLIOPISTO
Tel. +358 50 3199529
osma.suomi...@helsinki.fi
http://www.nationallibrary.fi


Re: completion with Lucene: desirable from SPARQL

2016-11-01 Thread Jean-Marc Vanel
I's too bad that the * joker feature, and other details of the SPARQL to
Lucene query translation, are not documented on the Jena text search page.

Anyway, it works for my use case, I now have on my laptop a (kind of)
replacement of dbPedia lookup service.

To experiment with the original dbPedia lookup service, you can go to
semantic_forms sandbox:
http://163.172.179.125:9111/create?uri==http%3A%2F%2Fxmlns.com%2Ffoaf%2F0.1%2FPerson
and type a few letters in the dct:subject field.

I don't need the full original literal value, because the URI results of
the query are labelled in the application: a foaf:Person is labelled by
given and family names, etc.

BUT, there is a "but", the dbPedia lookup service are apropriately ordered
by "notoriety".
Instead, I currently get with http://localhost:9000/lookup?q=*Pari*
on my TDB that mirrors dbPedia.



  Université Pierre-et-Marie-Curie
  http://dbpedia.org/resource/Pierre_and_Marie_Curie_University


  Guillaume Le Gentil
  http://dbpedia.org/resource/Guillaume_Le_Gentil

  1 E1 m
  http://dbpedia.org/resource/1_decametre

  1 E4 m
  http://dbpedia.org/resource/1_myriametre

  Nadia Boulanger
  http://dbpedia.org/resource/Nadia_Boulanger

  Luis Mariano
  http://dbpedia.org/resource/Luis_Mariano

  Paul Chemetov
  http://dbpedia.org/resource/Paul_Chemetov

  Marc Boegner
  http://dbpedia.org/resource/Marc_Boegner

  Cassandre (graphiste)
  http://dbpedia.org/resource/Cassandre_(artist)

  La Norville
  http://dbpedia.org/resource/La_Norville



My understanding is that I need to set a weight on URI's in Lucene to
reflect their "notoriety".
I see 2 ways:

   1. easy to implement: just count the triples from and to the URI
   2. also take in account the the URI's consulted by user in my
   application (but currently I don't record that information); there is
   also the issue of combining weights 1) and 2)

Google search does both weightings.

So, in the short term I have to figure out how to add weights to the Lucene
- Jena index.

Then I have to read what dbPedia lookup does, and other background material.



2016-10-31 16:42 GMT+01:00 Osma Suominen :

> Hi Jean-Marc,
>
> Depending on what exactly you want from such a service, this may be
> already possible with jena-text.
>
> I'm assuming that you want to perform a prefix search such as "édu*" and
> get possible completions for that, such as "éducation".
>
> You can of course already do a prefix search with jena-text. What you will
> get back will be the RDF resources which have labels that contain this
> prefix. If the text index is configured to store literal values, you can
> ask for the actual values as well.
>
> E.g. with this data:
>
> ex:cse rdfs:label "Conseil supérieur de l'éducation"@fr .
>
> and a suitably configured jena-text index, you can perform this query:
>
> (?s ?score ?literal) text:query (rdfs:label "édu*") .
>
> and get back these bindings:
>
> ?s=ex:cse ?literal="Conseil supérieur de l'éducation"@fr
>
> However, you will get the full original literal value, not just the
> individual word that matched ("éducation"). If you want just the matched
> word, you will need special support that jena-text doesn't currently have.
>
> -Osma
>
> On 17/10/16 11:37, Jean-Marc Vanel wrote:
>
>> Hi
>>
>> I'm implementing an equivalent of dbPedia lookup service [1] in
>> semantic_forms, leveraging on Lucene integration in TDB, and dbPedia
>> mirror
>> with TDB [2] .
>>
>> The dbPedia lookup service is really nice but:
>>
>> - the hosted service is often down
>> - completion is in english only
>>
>> A lookup service with TDB and Lucene would overcome these 2 problems.
>>
>> So I would need completion with Lucene from SPARQL.
>> According to Jena doc., this does not seems to be implemented:
>> https://jena.apache.org/documentation/query/text-query.html#
>> query-with-sparql
>>
>> There are plenty of pages when searching for
>> lucene completion
>>
>>  From these pages there is a code snippet here
>> http://stackoverflow.com/questions/120180/how-to-do-query-
>> auto-completion-suggestions-in-lucene
>> but a regular Lucene API may exist.
>>
>> [1] https://github.com/dbpedia/lookup
>> [2]
>> https://github.com/jmvanel/semantic_forms/blob/master/doc/
>> en/administration.md#populating-with-dbpedia-mirroring-dbpedia
>>
>>
>
> --
> Osma Suominen
> D.Sc. (Tech), Information Systems Specialist
> National Library of Finland
> P.O. Box 26 (Kaikukatu 4)
> 00014 HELSINGIN YLIOPISTO
> Tel. +358 50 3199529
> osma.suomi...@helsinki.fi
> http://www.nationallibrary.fi
>



-- 
Jean-Marc Vanel
Profil:
http://163.172.179.125:9111/display?displayuri=http%3A%2F%2Fjmvanel.free.fr%2Fjmv.rdf%23me
Déductions SARL - Consulting, services, training,