Search code examples
.netrdfsparqlsemantic-webdbpedia

downloading and setting up the dbpedia dump


I am trying to download the DBpedia dump to my local computer so that I can do queries locally. After taking a look at the Downloads I have some questions:

  • What exactly do I download?
  • How to load the dump into my RAM so that the results come faster?

NOTE: I am using the dotNetRDF libary to do the queries.


Solution

  • the nt files are the N-Triples you need to download into your computer, the reason for being so many nt files for one category is that they're categorized by language.

    after downloading the nt files, you need to add the following code to your .NET project after referencing the dotNetRDF dlls

            TripleStore temp = new TripleStore();          
            temp.AddFromUri(new Uri(/*path of nt file no.1*/), true);
            temp.AddFromUri(new Uri(/*path of nt file no.2*/), true);
            //keep adding Uris of all your nt files
    

    Now you've loaded the nt files, note that the english dbpedia dump is very large , you probably need very big RAM to load the triple store.

    if you want to do a query, just add this line of code:

            var d = temp.ExecuteQuery("select * 
                    where{#put your query here}");
            foreach (SparqlResult item in (SparqlResultSet)d)
            {
                //Do whatever you want to do with the results !!, 
                //ex:Console.WriteLine(item.ToString());
            }
    

    There're also another classes like TripleStore, like DiskDemandTripleStore, OnDemandTripleStore, SqlTripleStore, WebDemandTripleStore see the documentation for more info about these 'And other' Classes