acoli-repo / conll-rdf

Advanced graph rewriting and LLOD publication for CoNLL and other TSV formats
25 stars 9 forks source link

direct SPARQL update #74

Open chiarcos opened 2 years ago

chiarcos commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 .