Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

direct SPARQL update #74

Open
chiarcos opened this issue Nov 20, 2021 · 2 comments
Open

direct SPARQL update #74

chiarcos opened this issue Nov 20, 2021 · 2 comments
Labels

Comments

@chiarcos
Copy link
Contributor

Using bash, direct updates are split into separate substrings, and there is not a real workaround. In the following script, the query string is parsed into individual tokens, and the Updater tries to execute each single one as a SPARQL script.

 $> echo | run.sh CoNLLRDFUpdater -custom -updates "PREFIX conll: <http://ufal.mff.cuni.cz/conll2009-st/task-description.html#> INSERT { ?a conll:WORD ?b } WHERE { ?a conll:FORM ?b}; INSERT { ?a conll:POS ?b } WHERE { ?a conll:XPOS ?b}; "

msg:

  09:02:52 ERROR CoNLLRDFUpdater      :: Failed to parse argument as sparql
  09:02:52 ERROR CoNLLRDFUpdater      :: org.apache.commons.cli.ParseException: SPARQL parse exception for Update No. 1: DIRECTUPDATE
  org.apache.jena.query.QueryParseException: Encountered "<EOF>" at line 1, column 6.
  Was expecting:
      <PNAME_NS> ...

  PREFIX

There doesn't seem to be a way to escape that in Bash.

TODO: When reading the argument vector, concatenate arguments of -updates as soon as a any of them is not a file. (Note: leading - is not expected to occur in SPARQL.)

@cfaeth
Copy link
Collaborator

cfaeth commented Dec 3, 2021

This is not a bug but a missing feature. The CoNLLRDFUpdater was never designed to work with in-line Updates. Instead it was always meant to be used with references to script files. However, Leo will look into it and see if she can find an elegant way to handle this.

@leogott
Copy link
Contributor

leogott commented Jan 21, 2022

This issue appears to be fixed in main.
Using
run.sh CoNLLRDFUpdater -custom -updates "PREFIX conll: <http://ufal.mff.cuni.cz/conll2009-st/task-description.html#> INSERT { ?a conll:WORD ?b } WHERE { ?a conll:FORM ?b}; INSERT { ?a conll:POS ?b } WHERE { ?a conll:XPOS ?b}; "
and the input

@prefix : <http://example.org#>
@prefix conll: <http://ufal.mff.cuni.cz/conll2009-st/task-description.html#> .
:1 conll:FORM :2

@prefix : <http://example.org#>
@prefix conll: <http://ufal.mff.cuni.cz/conll2009-st/task-description.html#> .
:3 conll:FORM :4

I got

@prefix :      <http://example.org#> .
@prefix conll: <http://ufal.mff.cuni.cz/conll2009-st/task-description.html#> .

:1      conll:FORM  :2 ;
        conll:WORD  :2 .

@prefix :      <http://example.org#> .
@prefix conll: <http://ufal.mff.cuni.cz/conll2009-st/task-description.html#> .

:3      conll:FORM  :4 ;
        conll:WORD  :4 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants