tbloader vs SPARQL INSERT - Why different behaviour with named graphs?

后端 未结 1 1576
时光说笑
时光说笑 2021-01-19 00:09

There is a strange behaviour in the connection of the commandline tools of ARQ, TDB and Named Graphs. If importing data via tdbloader in a named graph it can not be queried

相关标签:
1条回答
  • 2021-01-19 01:00

    Try this query:

    PREFIX : <data>
    SELECT * { { ?s ?p ?o } UNION { GRAPH ?g { ?s ?p ?o } } }
    

    and the output is

    ----------------------------
    | s   | p   | o   | g      |
    ============================
    | <a> | <b> | <c> | <data> |
    | <d> | <e> | <f> | :      |
    ----------------------------
    

    or try:

     tdbquery --loc DB --file Q.rq -results srj
    

    to get the results in a different form.

    The text output is makign things look nice but two different things end up as <data>.

    What you are seeing is that

    tdbloader --desc tdb.ttl --graph data data.ttl
    

    used data exactly as is to name the graph. But

    INSERT DATA {GRAPH <data> {<d> <e> <f>.}}
    

    does a full SPARQL parse, and resolves against the base URI, probably looking like file://*currentdirectory*.

    When printing in text, URIs get abbreviated, including using the base. So both the original data (from tdbloader) and file:///path/data appear as <data>.

    PREFIX : <data>
    

    gives the text output a different way to write it as :.

    Finally try:

    BASE <http://example/>
    SELECT * { { ?s ?p ?o } UNION { GRAPH ?g { ?s ?p ?o } } }
    

    which sets the base URI to something no where near your data URIs so switching off nice formatting by base URI:

    ----------------------------------------------------------------------------------------------------------------
    | s                        | p                        | o                        | g                           |
    ================================================================================================================
    | <file:///home/afs/tmp/a> | <file:///home/afs/tmp/b> | <file:///home/afs/tmp/c> | <data>                      |
    | <file:///home/afs/tmp/d> | <file:///home/afs/tmp/e> | <file:///home/afs/tmp/f> | <file:///home/afs/tmp/data> |
    ----------------------------------------------------------------------------------------------------------------
    
    0 讨论(0)
提交回复
热议问题