You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jena.apache.org by "Kroll, Joshua E (CGI Federal)" <jo...@cgifederal.com> on 2015/03/17 21:07:24 UTC

Old RDB Versions JENA STRBEFORE / STRAFTER Missing

JENA Group,

I was pointed in this list serv's direction by the VIVO community. I am working on a data ingest process into VIVO though an application that has a rest API. We are currently still using the older version of JENA (jena-arq-2.8.7).

The problem with this version is that there is no STRBEFORE or STRAFTER functions. From what I can tell there are two paths forward. 1) refactor to use the new JENA versions that have the above SPARQL Queries 2) Try and Implement functions in current older version of JENA

I am not sure what is easiest as I have limited JENA working knowledge.

To give a better overview of what I am trying to do and the errors that are resulting:

QUERY:
PREFIX scoring: <http://vivoweb.org/harvester/model/scoring#<http://vivoweb.org/harvester/model/scoring>>
SELECT DISTINCT ?sVivo ?sInput str(?lNameVivo) str(?fNameVivo) str(?mInitialVivo) str(?abvNameVivo) str(?lNameHarv) str(?fNameHarv) str(?mInitialHarv) str(?abvNameHarv) ?os_label ?op_label
FROM NAMED <http://vivoweb.org/harvester/model/scoring#vivoClone>
FROM NAMED <http://vivoweb.org/harvester/model/scoring#inputClone>
WHERE {
  GRAPH scoring:vivoClone {
    ?sVivo <http://www.w3.org/2000/01/rdf-schema#label> ?op_label .
  } .
  GRAPH scoring:inputClone {
    ?sInput <http://www.w3.org/2000/01/rdf-schema#label> ?os_label .
  } .
  BIND(STRAFTER("ab, cc",", ") AS ?lNameVivo) .
}

ERROR:
2015-03-17 13:43:12.463 ERROR [o.v.h.s.Score] Lexical error at line 12, column 16.  Encountered: "(" (40), after : "AFTER"
2015-03-17 13:43:12.463 DEBUG [o.v.h.s.Score] Stacktrace:
com.hp.hpl.jena.query.QueryParseException: Lexical error at line 12, column 16.  Encountered: "(" (40), after : "AFTER"
at com.hp.hpl.jena.sparql.lang.ParserARQ.perform(ParserARQ.java:95) ~[arq-2.8.7.jar:na]

Which makes sense because the above ARQ constants file doesn't have strafter so it thinks I am trying to do str?

I am open to other options as well. I am trying to figure out if there is a better path forward or if anyone has resolved this type of problem before.

Let me know if anyone needs more information to better address the problem.

Thank you,

Josh Kroll

CGI Federal | O: 703-227-4131 | joshua.kroll@cgifederal.com<ma...@cgifederal.com>


RE: Old RDB Versions JENA STRBEFORE / STRAFTER Missing

Posted by "Kroll, Joshua E (CGI Federal)" <jo...@cgifederal.com>.
Sounds like (1) is the best option then. I will have to check what needs to be refactored with the updated of the JENA model libraries. Hopefully the code is not to tightly coupled with the old library.

The data is coming from Web of science and VIVO. The web of science data gets transformed into a TDB JENA model on the file system so that we can run SPARQL queries against it. And VIVO is already in RDF format so we can query VIVO directly from the data source.

Thank you for your feedback and if you can think of anything else that might help let me know.

Josh Kroll 

CGI Federal | O: 703-227-4131 | joshua.kroll@cgifederal.com

-----Original Message-----
From: Andy Seaborne [mailto:andy@apache.org] 
Sent: Tuesday, March 17, 2015 6:27 PM
To: users@jena.apache.org
Subject: Re: Old RDB Versions JENA STRBEFORE / STRAFTER Missing

Hi Josh,

Yes, I think (1) and (2) are basically the two options you have.  In this case, adding STRAFTER isn't to hard but there will be another function or feature and then another ... whereas (1) gets it all done once and for all and you can adopt standard SPARQL 1.1.  With (2) it's "just" a matter of hacking the parser, adding the generation of calls for additional functions and copying over the implementations from current Jena.  That codebase will then be yours to maintain.  (1) gets you onto the supported codebase.

There are lots of changes over the 4/5 years since arq-2.8.7.jar.

Where's the data coming from?

	Andy

On 17/03/15 20:07, Kroll, Joshua E (CGI Federal) wrote:
> JENA Group,
>
> I was pointed in this list serv's direction by the VIVO community. I am working on a data ingest process into VIVO though an application that has a rest API. We are currently still using the older version of JENA (jena-arq-2.8.7).
>
> The problem with this version is that there is no STRBEFORE or 
> STRAFTER functions. From what I can tell there are two paths forward. 
> 1) refactor to use the new JENA versions that have the above SPARQL 
> Queries 2) Try and Implement functions in current older version of 
> JENA
>
> I am not sure what is easiest as I have limited JENA working knowledge.
>
> To give a better overview of what I am trying to do and the errors that are resulting:
>
> QUERY:
> PREFIX scoring: 
> <http://vivoweb.org/harvester/model/scoring#<http://vivoweb.org/harves
> ter/model/scoring>> SELECT DISTINCT ?sVivo ?sInput str(?lNameVivo) 
> str(?fNameVivo) str(?mInitialVivo) str(?abvNameVivo) str(?lNameHarv) 
> str(?fNameHarv) str(?mInitialHarv) str(?abvNameHarv) ?os_label 
> ?op_label

The form "str(?var)" will not work in standard SPARQL 1.1 - it does work in ARQ extended syntax.

it needs an AS for SPARQL 1.1

(str(?var) AS ?varStr)

> FROM NAMED <http://vivoweb.org/harvester/model/scoring#vivoClone>
> FROM NAMED <http://vivoweb.org/harvester/model/scoring#inputClone>
> WHERE {
>    GRAPH scoring:vivoClone {
>      ?sVivo <http://www.w3.org/2000/01/rdf-schema#label> ?op_label .
>    } .
>    GRAPH scoring:inputClone {
>      ?sInput <http://www.w3.org/2000/01/rdf-schema#label> ?os_label .
>    } .

That's a disjoint cross product, hence the DISTINCT I guess but it is a 
very expensive way of doing it.   Did you mean UNION?

>    BIND(STRAFTER("ab, cc",", ") AS ?lNameVivo) .

No variable in STRAFTER?

> }
>
> ERROR:
> 2015-03-17 13:43:12.463 ERROR [o.v.h.s.Score] Lexical error at line 12, column 16.  Encountered: "(" (40), after : "AFTER"
> 2015-03-17 13:43:12.463 DEBUG [o.v.h.s.Score] Stacktrace:
> com.hp.hpl.jena.query.QueryParseException: Lexical error at line 12, column 16.  Encountered: "(" (40), after : "AFTER"
> at com.hp.hpl.jena.sparql.lang.ParserARQ.perform(ParserARQ.java:95) 
> ~[arq-2.8.7.jar:na]
>
> Which makes sense because the above ARQ constants file doesn't have strafter so it thinks I am trying to do str?
>
> I am open to other options as well. I am trying to figure out if there is a better path forward or if anyone has resolved this type of problem before.
>
> Let me know if anyone needs more information to better address the problem.
>
> Thank you,
>
> Josh Kroll
>
> CGI Federal | O: 703-227-4131 | 
> joshua.kroll@cgifederal.com<ma...@cgifederal.com>
>
>


Re: Old RDB Versions JENA STRBEFORE / STRAFTER Missing

Posted by Andy Seaborne <an...@apache.org>.
Hi Josh,

Yes, I think (1) and (2) are basically the two options you have.  In 
this case, adding STRAFTER isn't to hard but there will be another 
function or feature and then another ... whereas (1) gets it all done 
once and for all and you can adopt standard SPARQL 1.1.  With (2) it's 
"just" a matter of hacking the parser, adding the generation of calls 
for additional functions and copying over the implementations from 
current Jena.  That codebase will then be yours to maintain.  (1) gets 
you onto the supported codebase.

There are lots of changes over the 4/5 years since arq-2.8.7.jar.

Where's the data coming from?

	Andy

On 17/03/15 20:07, Kroll, Joshua E (CGI Federal) wrote:
> JENA Group,
>
> I was pointed in this list serv's direction by the VIVO community. I am working on a data ingest process into VIVO though an application that has a rest API. We are currently still using the older version of JENA (jena-arq-2.8.7).
>
> The problem with this version is that there is no STRBEFORE or STRAFTER functions. From what I can tell there are two paths forward. 1) refactor to use the new JENA versions that have the above SPARQL Queries 2) Try and Implement functions in current older version of JENA
>
> I am not sure what is easiest as I have limited JENA working knowledge.
>
> To give a better overview of what I am trying to do and the errors that are resulting:
>
> QUERY:
> PREFIX scoring: <http://vivoweb.org/harvester/model/scoring#<http://vivoweb.org/harvester/model/scoring>>
> SELECT DISTINCT ?sVivo ?sInput str(?lNameVivo) str(?fNameVivo) str(?mInitialVivo) str(?abvNameVivo) str(?lNameHarv) str(?fNameHarv) str(?mInitialHarv) str(?abvNameHarv) ?os_label ?op_label

The form "str(?var)" will not work in standard SPARQL 1.1 - it does work 
in ARQ extended syntax.

it needs an AS for SPARQL 1.1

(str(?var) AS ?varStr)

> FROM NAMED <http://vivoweb.org/harvester/model/scoring#vivoClone>
> FROM NAMED <http://vivoweb.org/harvester/model/scoring#inputClone>
> WHERE {
>    GRAPH scoring:vivoClone {
>      ?sVivo <http://www.w3.org/2000/01/rdf-schema#label> ?op_label .
>    } .
>    GRAPH scoring:inputClone {
>      ?sInput <http://www.w3.org/2000/01/rdf-schema#label> ?os_label .
>    } .

That's a disjoint cross product, hence the DISTINCT I guess but it is a 
very expensive way of doing it.   Did you mean UNION?

>    BIND(STRAFTER("ab, cc",", ") AS ?lNameVivo) .

No variable in STRAFTER?

> }
>
> ERROR:
> 2015-03-17 13:43:12.463 ERROR [o.v.h.s.Score] Lexical error at line 12, column 16.  Encountered: "(" (40), after : "AFTER"
> 2015-03-17 13:43:12.463 DEBUG [o.v.h.s.Score] Stacktrace:
> com.hp.hpl.jena.query.QueryParseException: Lexical error at line 12, column 16.  Encountered: "(" (40), after : "AFTER"
> at com.hp.hpl.jena.sparql.lang.ParserARQ.perform(ParserARQ.java:95) ~[arq-2.8.7.jar:na]
>
> Which makes sense because the above ARQ constants file doesn't have strafter so it thinks I am trying to do str?
>
> I am open to other options as well. I am trying to figure out if there is a better path forward or if anyone has resolved this type of problem before.
>
> Let me know if anyone needs more information to better address the problem.
>
> Thank you,
>
> Josh Kroll
>
> CGI Federal | O: 703-227-4131 | joshua.kroll@cgifederal.com<ma...@cgifederal.com>
>
>