(This page is still under construction.)

Some help (such as sample SPARQL queries) can be found on answers.semanticweb.com and/or Stack Overflow. The most recent 10 posts for each site should be seen in the Feeds section, lower down on this page. Full searches are linked here --

If the information you need cannot be found there, you can:

  1. create a new post on one of the Overflow sites and use the tag “dbpedia”
  2. check the DBpedia support page .


(Still not displayed correctly, we are working on aggregating the feed)


dbpedia query

Hello all! I want to query dbpedia link text so that it shows the external links of every object separated by "," and i am writing:

SELECT ?x ?title (group_concat(distinct ?ext;separator="; ") as ?exts)
      {   ?x rdfs:label ?title .
          ?x dbpedia-owl:wikiPageExternalLink ?ext .
      } GROUP BY ?x ?title ?exts

But I am getting an error "Virtuoso 37000 Error SP031: SPARQL compiler: Variable 'exts' is used in the query result set but not assigned"

What am i doing wrong?

Thanks a lot!

How to traverse skos:broader property

Any help in my learning will be highly appreciated.

Problem statement:

Need to print list of tourist places in various cities

I have http://dbpedia.org/page/Category:Tourism_by_city category which i have to explore. The problem is this category is a skos:broader of various other categories like http://dbpedia.org/page/Category:Tourism_in_Bratislava which in itself is a skos:broader of http://dbpedia.org/page/Category:Visitor_attractions_in_Bratislava which contains dcterms:subject property and which is the list of tourist places. I have to explore all cities starting from Tourism_by_city category.

Please do let me know if question is unclear. Thanks

bulk loading DBpedia in Virtuoso

I am trying to load dbpedia datasets onto Virtuoso on windows 7.

I use the command ld_dir and I follow it with SELECT * FROM DB.DBA.LOAD_LIST; and it seems to be fine. But once I run the rdf_load_run the laptop keeps beeping and command line freezes, until I close it.

I tried modifying the NumberOfBuffers and the MaxDirtyBuffers in virtuoso.ini but that did not have any effect. I also tried with the quand store upload, but that didnt work either.

Does that mean that the 4 GB RAM I have is not enough to upload it?

Extract a subset of triples from Jena TDB database

I downloaded several of the datasets from dbpedia.org, because I am creating a quiz application where I will use data from dbpedia for creating questions and answers.

The problem is that after loading the datasets into my TDB database, the database is now about 10GB, and I still need to add some more data from dbpedia. The last dataset I added took almost 2 days to add and many queries are now very slow.

Is there any way for me to extract a smaller subset from my current TDB database and use only this subset for the database in my quiz application? For instance at first I would like to extract all persons with a yago category containing the strings "Norway" or "Norwegian" and all data directly related to these persons.

I have read about CONSTRUCT queries, but am not sure if this is what I am looking for.


how to query dbpedia using jena java?

Hello everyone and experts, i am novice user in using sparql query for dbpedia data. what I want to do is to query the Computer Scientist publications DBLP in java: like this following link do http://dbpedia.org/snorql/?query=SELECT+*+WHERE+%7B%0D%0A%3Fsubject+owl%3AsameAs+%3Flink.%0D%0A%3Fsubject+rdf%3Atype+%3Chttp%3A%2F%2Fdbpedia.org%2Fclass%2Fyago%2FProgrammer110481268%3E%0D%0A%7D+LIMIT+20 I use that query in java as follows.

String service = "http://dbpedia.org/sparql";
String query="  PREFIX owl: <http://www.w3.org/2002/07/owl#>"+
"PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>"+
"PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>"+
"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>"+
"PREFIX foaf: <http://xmlns.com/foaf/0.1/>"+
"PREFIX dc: <http://purl.org/dc/elements/1.1/>"+
"PREFIX : <http://dbpedia.org/resource/>"+
"PREFIX dbpedia2: <http://dbpedia.org/property/>"+
"PREFIX dbpedia: <http://dbpedia.org/>"+
"PREFIX skos: <http://www.w3.org/2004/02/skos/core#>"+
    "SELECT * WHERE {"+
    "?subject owl:sameAs ?link."+
    "?subject rdf:type <http://dbpedia.org/class/yago/Programmer110481268>"+
    "} LIMIT 20";

            QueryExecution qe=QueryExecutionFactory.sparqlService(service, query);
            ResultSet rs=qe.execSelect();

that code gave following error

Exception in thread "main" HttpException: java.net.SocketException: Connection reset: java.net.SocketException: Connection reset
at com.hp.hpl.jena.sparql.engine.http.HttpQuery.execCommon(HttpQuery.java:333)

but the other code can link the dbpedia and give the results, but, they are not what I wanted.

String sparqlQueryString = "select distinct ?Concept where {[] a ?Concept } LIMIT 10";
Query query = QueryFactory.create(sparqlQueryString);
QueryExecution qexec = QueryExecutionFactory.sparqlService("http://dbpedia.org/sparql", query);

So, anyone has some idea to query in java like they do in "http://wiki.dbpedia.org/Datasets" Any help is appreciated and thanks you very much in advance.

Query combination using multiple subqueries

I want to count the predicates between two set of entities. Each set has entities of the same DBpedia class (i.e. Person or Organisation). Moreover, each entity E has a certain class C as rdf:type and no other rdf:type x where x is a subclass of C.

Hence, for retrieving one entity set (Person) we can run this query:

PREFIX dbp: <http://dbpedia.org/ontology/>
SELECT ?e1 {
    ?e1 a dbp:Person .
        ?subclass1 rdfs:subClassOf+ dbp:Person . 
        ?e1 a ?subclass1 .
        FILTER (?subclass1 != dbp:Person ) . 

We can do the same thing for the other set (Organisation):

PREFIX dbp: <http://dbpedia.org/ontology/>
SELECT ?e2 {
    ?e2 a dbp:Organisation .
        ?subclass2 rdfs:subClassOf+ dbp:Organisation . 
        ?e2 a ?subclass2 . 

I combined the two queries in this way for achieving the purpose described above:

PREFIX dbp: <http://dbpedia.org/ontology/>
SELECT (COUNT(?p) AS ?cont) {
    ?e1 ?p ?e2 .
    ?e1 a dbp:Person .
    ?e2 a dbp:Organisation .
        ?subclass1 rdfs:subClassOf+ dbp:Person . 
        ?e1 a ?subclass1 .
        FILTER (?subclass1 != dbp:Person ) . 
        ?subclass2 rdfs:subClassOf+ dbp:Organisation . 
        ?e2 a ?subclass2 . 
        FILTER (?subclass2 != dbp:Organisation ) . 

The endpoint return this error. So, i rewrite the query using subqueries (I do not perform the count for checking the entity results):

PREFIX dbp: <http://dbpedia.org/ontology/>
SELECT ?e1 ?p ?e2 {
?e1 ?p ?e2 .

{SELECT ?e1 {
    ?e1 a dbp:Person .
        ?subclass1 rdfs:subClassOf+ dbp:Person . 
        ?e1 a ?subclass1 .
        FILTER (?subclass1 != dbp:Person ) . 

{SELECT ?e2 {
    ?e2 a dbp:Organisation .
        ?subclass2 rdfs:subClassOf+ dbp:Organisation . 
        ?e2 a ?subclass2 . 
        FILTER (?subclass2 != dbp:Organisation ) . 

This are the results. The problem is that while the results of the two subqueries are correct, if executed separately as shown above (first two query of the answer), the results of the combination query have entities like this one. It has rdf:type dbp:Agent and dbp:Person but it has also dbp:Scientist.

Considering that the results of the subqueries (first two query of the answer) are correct, why in the combination query there's this behaviour? Why there are undesired entities that are not included in the previous queries?

I hope the answer is clear. Thank you in advance

DBpedia Entities, rdf:type and Ontology sub-classes

I'm trying to build a query that given a certain ontology class C (like Person) returns the entities that have the rdf:type C and no other rdf:type x where x is a subclass of C (Person) and it belongs to the DBpedia ontology.

Hence if an entity has rdf:type http://dbpedia.org/ontology/Person and rdf:type http://schema.org/Person is accepted. An entity with rdf:type http://dbpedia.org/ontology/Agent and rdf:type http://dbpedia.org/ontology/Person is accepted because Agent is the father of Person in the hierarchy.

I tried to write the query in this way:

PREFIX dbp: <http://dbpedia.org/ontology/>

    ?subclass rdfs:subClassOf+ dbp:Person .
    ?entity a dbp:Person .
    FILTER NOT EXISTS {?entity a ?subclass}

The results contain entities that do not fit my description above. For instance the second entity in the results has rdf:type Person but also Politician and President that are subclasses of Person.

Any hints to improve the query? (I know that the query can be built using a COUNT but I'm wonder if it is possible to write it also using rdfs:subClassOf and FILTER NOT EXISTS)

Thank you in advance

How to know the number of recursions needed in a (rdfs:subClassOf)* for each class found ?

Let's consider, for instance, this query - on DBPedia :

construct { 
    yago:Instrumentality103575240 rdfs:subClassOf ?class
} where {
    yago:Instrumentality103575240 (rdfs:subClassOf)* ?class .

Which returns

yago:Instrumentality103575240   rdfs:subClassOf yago:Whole100003553 ,
        yago:PhysicalEntity100001930 ,
        yago:Artifact100021939 ,
        yago:Instrumentality103575240 ,
        yago:Object100002684 .

How can I know, for each class, the number of rdfs:subClassOf (= nb. of recursions) that have been processed to retrieve it ? I.e., how deeply we have to go through each (top)class ? For example : yago:Artifact100021939 == 1 recursion, yago:Whole100003553 == 2 recursion, etc.


ps: sorry for this poorly formuled question, I did not know how to explain this clearly

How to understand the use of dcterms:subject in dbpedia?

DBpedia says about Leonardo da Vinci (among other things):

dbpedia:Leonardo_da_Vinci a foaf:Person ;
    dcterms:subject category:Renaissance_painters.
category:Renaissance_painters a skos:Concept .

Since DC defines subject as "The topic of the resource" and of course FOAF defines Person as a person, my question is: How to understand a person having a topic?

Link ontologies from DBpedia to external ones with sameAS

Is there a way in SPARQL to automatically connect instances of one ontology in DBpedia and another in a different database. For example

http://yago-knowledge.org/resource/Daphne_Gere and http://dbpedia.org/page/Daphne_Gere

are similar and connect with the propriety sameAs, but I would like to be able to do it for all instances of the ontologies where they belong

http://yago-knowledge.org/resource/wordnet_actor_109765278 and http://dbpedia.org/ontology/Actor

So for example the result will be a table that has all the instances from one class with their equivalent in the other class.

There are no files on this page. [Display files/form]
There is no comment on this page. [Display comments/form]


Last Modification: 2011-07-24 20:04:59 by Sebastian Hellmann