virtuoso-opensource icon indicating copy to clipboard operation
virtuoso-opensource copied to clipboard

Why can I not upload this quad onto Virtuoso; even if uploaded, why can I not query with SPARQL?

Open candlecao opened this issue 1 year ago • 7 comments

I cannot upload a file with the suffix .nq onto Virtuoso. The content in the file is:

@prefix wdt: <http://www.wikidata.org/prop/direct/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

<https://thesession.org/recordings/1032> <https://thesession.org/tunes> <https://thesession.org/tunes/1> <urn:relationship:1032_1> .
<https://thesession.org/tunes/1> wdt:P658 "12"^^xsd:int <urn:relationship:1032_1> .
<https://thesession.org/tunes/1> wdt:P1114 "1"^^xsd:int <urn:relationship:1032_1> .

<https://thesession.org/recordings/1032> <https://thesession.org/tunes> <https://thesession.org/tunes/629> <urn:relationship:1032_629> .
<https://thesession.org/tunes/629> wdt:P658 "12"^^xsd:int <urn:relationship:1032_629> .
<https://thesession.org/tunes/629> wdt:P1114 "2"^^xsd:int <urn:relationship:1032_629> .

<https://thesession.org/recordings/3536> <https://thesession.org/tunes> <https://thesession.org/tunes/1> <urn:relationship:3536_1> .
<https://thesession.org/tunes/1> wdt:P658 "23"^^xsd:int <urn:relationship:3536_1> .
<https://thesession.org/recordings/3536> <https://thesession.org/tunes/1> wdt:P1114 "1"^^xsd:int <urn:relationship:3536_1> .

However, if I don't use the namespace prefixes, see below, then I can upload the file onto Virtuoso:

<https://thesession.org/recordings/1032> <http://example.org/includes> <https://thesession.org/tunes/1> <urn:relationship:1032_1> .
<https://thesession.org/recordings/1032> <http://www.wikidata.org/prop/direct/P658> "12"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:1032_1> .
<https://thesession.org/tunes/1> <http://www.wikidata.org/prop/direct/P1114> "1"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:1032_1> .

<https://thesession.org/recordings/1032> <http://example.org/includes> <https://thesession.org/tunes/629> <urn:relationship:1032_629> .
<https://thesession.org/recordings/1032> <http://www.wikidata.org/prop/direct/P658> "12"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:1032_629> .
<https://thesession.org/tunes/629> <http://www.wikidata.org/prop/direct/P1114> "2"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:1032_629> .

<https://thesession.org/recordings/3536> <http://example.org/includes> <https://thesession.org/tunes/1> <urn:relationship:3536_1> .
<https://thesession.org/recordings/3536> <http://www.wikidata.org/prop/direct/P658> "23"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:3536_1> .
<https://thesession.org/tunes/1> <http://www.wikidata.org/prop/direct/P1114> "1"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:3536_1> .

Why?

candlecao avatar Aug 21 '24 16:08 candlecao

And I cannot query the graph in SPARQL.

candlecao avatar Aug 21 '24 16:08 candlecao

How are the graphs being uploaded to Virtuoso ?

HughWilliams avatar Aug 21 '24 18:08 HughWilliams

@candlecao

The NQuad file format have no syntax for @prefix see https://www.w3.org/TR/rdf12-n-quads/#sec-grammar-grammar Thus the 1st snippet is NOT Nquad, it is rather Turtle.

HTH

imitko avatar Aug 21 '24 19:08 imitko

@candlecao

The NQuad file format have no syntax for @prefix see https://www.w3.org/TR/rdf12-n-quads/#sec-grammar-grammar Thus the 1st snippet is NOT Nquad, it is rather Turtle.

HTH

Thank you! But how to query the file in SPARQL? It seems that we cannot use the normal select * where{?s ?p ?o} method. I asked ChatGpt, and it told me to query like:

SELECT * where {
  graph ?g {
    ?s ?p ?o
  }
}

But it doesn't work.

candlecao avatar Aug 22 '24 12:08 candlecao

How are the graphs being uploaded to Virtuoso ?

I uploaded it from Conductor > Linked Data > Quad Store Upload. And I found that it doesn't matter whether the quad file is with .nq format or .ttl format.

candlecao avatar Aug 22 '24 12:08 candlecao

The second NQUAD dataset you provided, i.e.:

<https://thesession.org/recordings/1032> <http://example.org/includes> <https://thesession.org/tunes/1> <urn:relationship:1032_1> .
<https://thesession.org/recordings/1032> <http://www.wikidata.org/prop/direct/P658> "12"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:1032_1> .
<https://thesession.org/tunes/1> <http://www.wikidata.org/prop/direct/P1114> "1"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:1032_1> .

<https://thesession.org/recordings/1032> <http://example.org/includes> <https://thesession.org/tunes/629> <urn:relationship:1032_629> .
<https://thesession.org/recordings/1032> <http://www.wikidata.org/prop/direct/P658> "12"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:1032_629> .
<https://thesession.org/tunes/629> <http://www.wikidata.org/prop/direct/P1114> "2"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:1032_629> .

<https://thesession.org/recordings/3536> <http://example.org/includes> <https://thesession.org/tunes/1> <urn:relationship:3536_1> .
<https://thesession.org/recordings/3536> <http://www.wikidata.org/prop/direct/P658> "23"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:3536_1> .
<https://thesession.org/tunes/1> <http://www.wikidata.org/prop/direct/P1114> "1"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:3536_1> .

loads fine for me and I can see the 3 graphs created with triple counts:

graph                                     count
urn:relationship:1032_1           3
urn:relationship:3536_1           3
urn:relationship:1032_629      3

What is the Virtuoso version being used and what does the output of running the following query to list and count triples in graph report:

SELECT ?graph ( COUNT ( ?s ) as ?count ) 
WHERE { GRAPH ?graph { ?s ?p ?o } } 
GROUP BY ?graph 
ORDER BY DESC(?count)

HughWilliams avatar Aug 22 '24 14:08 HughWilliams

Thank you, I will try referring to your advice later.

candlecao avatar Aug 26 '24 22:08 candlecao

@HughWilliams Hi, I tried. It worked. However, if I upload the data

<https://thesession.org/recordings/1032> <http://example.org/includes> <https://thesession.org/tunes/1> <urn:relationship:1032_1> .
<https://thesession.org/recordings/1032> <http://www.wikidata.org/prop/direct/P658> "12"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:1032_1> .
<https://thesession.org/tunes/1> <http://www.wikidata.org/prop/direct/P1114> "1"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:1032_1> .

<https://thesession.org/recordings/1032> <http://example.org/includes> <https://thesession.org/tunes/629> <urn:relationship:1032_629> .
<https://thesession.org/recordings/1032> <http://www.wikidata.org/prop/direct/P658> "12"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:1032_629> .
<https://thesession.org/tunes/629> <http://www.wikidata.org/prop/direct/P1114> "2"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:1032_629> .

<https://thesession.org/recordings/3536> <http://example.org/includes> <https://thesession.org/tunes/1> <urn:relationship:3536_1> .
<https://thesession.org/recordings/3536> <http://www.wikidata.org/prop/direct/P658> "23"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:3536_1> .
<https://thesession.org/tunes/1> <http://www.wikidata.org/prop/direct/P1114> "1"^^<http://www.w3.org/2001/XMLSchema#int> <urn:relationship:3536_1> .

to Virtuoso as an entire graph named http://example/quads, then if I want to check all the content in this http://example/quads. How should I write the SPARQL?

candlecao avatar Nov 06 '24 22:11 candlecao

I don't understand what you are asking. An NQUAD dataset includes the graph name into which each triple should be loaded in the dataset, which will override any graph name you may specify in the load command, which is the whole point of an NQUAD dataset. So nothing will be loaded into the http://example/quads name you might have specified in the load command.

HughWilliams avatar Nov 06 '24 22:11 HughWilliams

@candlecao — following on @HughWilliams's comments —

Note that a quad is comprised of a triple plus a graph name. There is no "quint" that would somehow comprise a quad plus a graph name, which would be a triple plus a graph name plus another graph name.

When loading a document containing a number of triples, you can specify the graph into which those triples will be loaded.

When loading a document containing a number of quads, on the other hand, the graph into which each triple will be loaded is specified within the quad; any graph specified in the load command will simply be ignored.

Hopefully this provides some clarification.

TallTed avatar Nov 07 '24 15:11 TallTed

Thank you. So I understand that http://example/quads on the uploading step just makes no sense for retrieval.

candlecao avatar Nov 07 '24 20:11 candlecao