0

I loaded two .nq files into TDB using the following code:

Dataset dataset = TDBFactory.createDataset("<path to directory with .nq files>"); 
Model tdb = dataset.getDefaultModel();
for (File file : folder.listFiles()) {
    FileManager.get().readModel(tdb, file.getPath(),"N-TRIPLES");
}

After loading the data, I ran some simple queries for labels etc. which all worked.

What I am actually interested in, however, is found in separate graphs. Unfortunately, whenever I try to access data in such a graph, the query fails. My question is similar in nature as this one (I also tried all the graph selects as the user asking the questions, but the answer the user provided does not work for me).

The following query returns no results even though there should be quite a few graphs:

  SELECT * WHERE { GRAPH ?g { ?s ?p ?o }}

I am very new to TDB and not very experienced. Did I load the data incorrectly or do I have to pay attention to some detail when I do the query?

The data is public you can find it here: http://webisa.webdatacommons.org/ (scroll down until you are at Data Dumps). All the graph queries work on the public endpoint but not on my TDB data set.

Janothan
  • 446
  • 4
  • 16
  • Your sample code shows that you loaded `N-Triples`, thus, where do you see graphs? – UninformedUser May 08 '18 at 03:11
  • 1
    How do you load the `N-QUADS` data to your TDB instance? That's the most important part. – UninformedUser May 08 '18 at 09:11
  • Thank you for your help. I imported the data using the first 4 lines of code given in the first part of my post. What do I have to change in order to make it work? – Janothan May 08 '18 at 09:29
  • Don't you have an error because you read a `N-Quads` file into a `N-Triples` Dataset? I don't know if the `Quads` can be cast in `Triples` as you did. Perhaps should you modify your `read`. – Gilles-Antoine Nys May 08 '18 at 09:39
  • 1
    The code reads into a model (single graph). There are never going to be named graphs if you read into the default graph. Read, using `RDFDataMgr.read(dataset, "filename")`. – AndyS May 08 '18 at 10:41
  • 1
    Your N-Quad data must be the triples, not named graphs, for that code to work at all. You need to create the named graph (`dataset.getNamedModel`) and read a file into that. – AndyS May 08 '18 at 10:45

1 Answers1

0

The problem was caused by the loading process of the data. In a second attempt, I used tdbloader in the command line which lead to a dataset which can process the desired graph queries using tdbquery.

Thank you very much for all your help.

Janothan
  • 446
  • 4
  • 16