(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 .

Feeds

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

answers.semanticweb.com

SPARQL - How to know which DBpedia endpoint to use and what resources I can query in the endpoint?

I studied some resources on the web, and I get to know something about SPARQL and DBpedia. However, I don't know if I want to find certain knowledge, how should I get the right endpoint and what resources I can query in the endpoint.

Let me explain my question by an example:

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

    SELECT ?manufacturer ?name ?car
    WHERE {
        ?car <http://purl.org/dc/terms/subject> <http://dbpedia.org/resource/Category:Luxury_vehicles> .
        ?car foaf:name ?name .
        ?car dbo:manufacturer ?man .
        ?man foaf:name ?manufacturer
    }
    ORDER by ?manufacturer ?name

This is an example query that can query for luxury cars.

My question is I don't know how I can specify correct

1.PREFIX dbo: http://dbpedia.org/ontology/

2.car http://purl.org/dc/terms/subject http://dbpedia.org/resource/Category:Luxury_vehicles If I want to find the information about apple, how to know the resource url?

3.dbo:manufacturer How do I know I can query about manufacturer?

Thanks~

Avoid cross join in a SPARQL query

I'm trying to do a SPARQL query but the result of this query seems to be a cross join. How can I solve this problem??

This is my query

SELECT ?name ?birthPlace ?lat ?long WHERE {
      ?s rdf:type dbpedia-owl:Philosopher.
      ?s rdfs:label ?name.
      ?s dbpedia-owl:birthPlace ?birthPlace .
      ?birthPlace wgs84_pos:lat ?lat .
      ?birthPlace wgs84_pos:long ?long .
} LIMIT 50

The result seems to be a Cartesian product but I need to show only unique data. How can I avoid this cross join?

Running the query here http://factforge.net/sparql the result seems to be a cross product.

This is the full query with prefixes:

  PREFIX dbpedia-owl: <http://dbpedia.org/ontology/> 
  PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
  PREFIX wgs84_pos: <http://www.w3.org/2003/01/geo/wgs84_pos#>
  PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

  SELECT ?name ?birthPlace ?lat ?long WHERE {
    ?s rdf:type dbpedia-owl:Philosopher.
    ?s rdfs:label ?name.
    ?s dbpedia-owl:birthPlace ?birthPlace .
    ?birthPlace wgs84_pos:lat ?lat .
    ?birthPlace wgs84_pos:long ?long .
  } LIMIT 50

Newbie: SPARQL, dbpedia, some direction would be handy :)

Almost embarrassed to ask but still learning the basics.

If a standard SQL query was

SELECT drug_name, side_effects FROM drug_database WHERE drug_name="Crestor";

Can you please advise me how I would get the same from dbpedia using e.g. http://dbpedia.org/sparql

I guess I am struggling with knowing how to "plan" a query as well as write one because I have yet to learn more about the dbpedia and the approach.

Any tips will be most appreciated.

Combined SPARQL query between DBpedia and my own RDF

Hello! Sorry for my English. I haven't got a lot of background in programming. I'm trying to make a combined query in Jena to DBpedia and a RDF file created by me. My purpose is to get the population data from DBpedia for some entities in my RDF that have defined a homologous one in DBpedia. ¿How can I get make this query correctly? My code in Eclipse is:


String queryString =

    "PREFIX abs: http://localhost/ontologies/2013/AirBaseStationsOntology.owl# " +
    "PREFIX dc: http://purl.org/dc/elements/1.1/ " +
    "PREFIX geo: http://www.w3.org/2003/01/geo/wgs84_pos# " +
    "PREFIX owl: http://www.w3.org/2002/07/owl# " +
    "PREFIX dbont: http://dbpedia.org/ontology/ "+
    "PREFIX dbp: http://dbpedia.org/property/ "+

    "SELECT ?place ?p ?population" +
    "FROM http://localhost:82/rdf-xml-6.rdf " +
    "FROM http://dbpedia.org/sparql " +
    "WHERE {  "+
    " <http://localhost/ontologies/2013/ABS/Station_ES1492A> abs:hasLocation ?place . " +
    " ?place owl:sameAs ?p . " +
    " ?p dbont:populationTotal ?population . " +
    "} ";

Query query = QueryFactory.create(queryString);

QueryExecution qe = QueryExecutionFactory.create(query); ResultSet results = qe.execSelect();

ResultSetFormatter.out(System.out, results, query);

qe.close();


Thank you in advance!

Uploading dbpedia mappingbased_properties_en.nt to Sesame 2.7

Has anyone done that because I'm super frustrated now. Initially I got some problems with unknown datatypes which @Jeen Broekstra helped me to get sorted here. Now my connection is unexpectedly getting terminated (I reckon) because I can see:

17:21:15.387 WARN [main][org.openrdf.sail.nativerdf.NativeStoreConnection] Rolling back transaction due to connection close java.lang.Throwable at org.openrdf.sail.helpers.SailConnectionBase.close(SailConnectionBase.java:240) at org.openrdf.sail.helpers.SailConnectionWrapper.close(SailConnectionWrapper.java:88) at org.openrdf.repository.sail.SailRepositoryConnection.close(SailRepositoryConnection.java:129) at com.intelli.sesame.UploadFilesTest.test(UploadFilesTest.java:69) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197) 2013-05-19 17:21:20.370 java[16086:9607] Unable to obtain JNIEnv for context: 0x0 17:21:20.695 ERROR [main][org.openrdf.sail.nativerdf.NativeStoreConnection] Encountered an unexpected problem while trying to roll back java.util.NoSuchElementException at java.util.LinkedList.remove(LinkedList.java:788) at java.util.LinkedList.removeLast(LinkedList.java:144) at org.openrdf.sail.nativerdf.btree.BTree$RangeIterator.popStacks(BTree.java:2223) at org.openrdf.sail.nativerdf.btree.BTree$RangeIterator.close(BTree.java:2192) at org.openrdf.sail.nativerdf.TripleStore.rollback(TripleStore.java:984) at org.openrdf.sail.nativerdf.NativeStoreConnection.rollbackInternal(NativeStoreConnection.java:361) at org.openrdf.sail.helpers.SailConnectionBase.close(SailConnectionBase.java:244) at org.openrdf.sail.helpers.SailConnectionWrapper.close(SailConnectionWrapper.java:88) at org.openrdf.repository.sail.SailRepositoryConnection.close(SailRepositoryConnection.java:129) at com.intelli.sesame.UploadFilesTest.test(UploadFilesTest.java:69) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44) at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229) at org.junit.runners.ParentRunner.run(ParentRunner.java:309) at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50) at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390) at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

I'd appreciate if you can give me any advise on how to debug that or any suggestions on what the issue might be. I have plenty of memory although the file is quite big... but even if I split it into smaller chunks still getting the same... not a memory issue. Why am I loosing the conn without an error being thrown?

UPDATE I am running Java 7.21 under OS X

My test code is as follows:

public class UploadFilesTest {

@Test public void test() {

    File repoDir = new File(
            "/Users/todorkolev/Documents/dev/tk/openrdf-sesame-2.7.0/repos");
    String indexes = "spoc,posc,cosp";
    Repository repo = new SailRepository(new ForwardChainingRDFSInferencer(new NativeStore(repoDir, indexes)));
    File file = new File("/Users/todorkolev/Documents/dev/tk/dbpedia/mappingbased_properties_en.nt");
    RepositoryConnection repoConn = null;
    try {
        repo.initialize();
        repoConn = repo.getConnection();
        // set the parser to report the error in the log,
        // but not to throw an exception when datatype verification fails
        repoConn.getParserConfig()
                .setNonFatalErrors(
                        new HashSet<RioSetting<?>>(
                                Arrays.asList(BasicParserSettings.FAIL_ON_UNKNOWN_DATATYPES)));
        repoConn.add(file, "http://dbpedia.org/mappingbased_properties_en.nt", RDFFormat.N3);
    } catch (RepositoryException e) {
        e.printStackTrace();
    } catch (RDFParseException e) {
        e.printStackTrace();
    } catch (IOException e) {
        e.printStackTrace();
    } finally {
        try {
            repoConn.close();
        } catch (RepositoryException e) {
            e.printStackTrace();
        }
    }

}

}

Retrieving music genre from artist DBPEDIA

Hello everybody, I want to retrieve the genre for a specific artist using SPARQL.

This is my query:

PREFIX prop: <http://dbpedia.org/property/>
PREFIX onto: <http://dbpedia.org/ontology/>
SELECT DISTINCT ?genre
WHERE {
    ?genre   onto:genre "Eminem" .
}

I expect to get:

dbpedia-owl:genre   dbpedia:Hip_hop_music

as in http://dbpedia.org/page/Eminem but I'm getting no results...

What is wrong in my query?

sesame dbpedia import - not recognised datatype

Hi,

I'm trying to import the following triples from dbpedia to local instance of sesame 2.7 native store:

http://dbpedia.org/resource/Anna_Kournikova> http://dbpedia.org/ontology/plays> "Right-handed (two-handed backhand)"@en . http://dbpedia.org/resource/Anna_Kournikova> http://dbpedia.org/ontology/careerPrizeMoney> "3584662.0"^^http://dbpedia.org/datatype/usDollar> .

(sorry for the missing angle brackets... don't know how to escape them)

I am getting the following: '3584662.0' was not recognised, and could not be verified, with datatype http://dbpedia.org/datatype/usDollar [line 2]

My question is how to add that missing datatype. As much as I managed to find info on the web http://dbpedia.org/datatype/usDollar is not currently added to the dbpedia ontology.

Any suggestions?

Country ownership of a structure

I'm currently trying to use dbpedia to put together a geopolitical map of military structures around the world and display them in a nice visual format, with the possibility to view structures by type, location, etc. For now, I'm only trying to get military airbases. The query I'm using right now to test this:

PREFIX g: http://www.w3.org/2003/01/geo/wgs84_pos#
PREFIX onto: http://dbpedia.org/ontology/
PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema#
PREFIX georss: http://www.georss.org/georss/
PREFIX dbpprop: http://dbpedia.org/property/
PREFIX skos: http://www.w3.org/2004/02/skos/core#
PREFIX category: http://dbpedia.org/resource/Category:
PREFIX dc: http://purl.org/dc/terms/
PREFIX template: http://dbpedia.org/resource/Template:

SELECT *
WHERE {
    ?subject dbpprop:wikiPageUsesTemplate template:Infobox_airport .
    ?subject dbpprop:type ?type .
    ?subject georss:point ?geo .
    ?subject rdfs:label ?label .
    FILTER (lang(?label) = "en" && REGEX(STR(?type), "Military", "i")) .
}
LIMIT 5

I'm happy with the way the query works so far, but I can't seem to obtain ownership information about each structure, for example - Airbase A is owned and operated by Country B. Is there a way I could update the query to include this information? I know I can use the geolocation data to find out the location country, but that doesn't necessarily mean that the country owns the airbase/structure.

Thanks!

PS - don't worry about the prefixes, I know the URLs are supposed to be wrapped in < ... > but Markdown tries to turn them into links.

Excluding structures that are abandoned/not in use

I'm currently trying to use dbpedia to put together a geopolitical map of military structures around the world and display them in a nice visual format, with the possibility to view structures by type, location, etc. For now, I'm only trying to get military airbases. The query I'm using right now to test this:

PREFIX g: http://www.w3.org/2003/01/geo/wgs84_pos#
PREFIX onto: http://dbpedia.org/ontology/
PREFIX rdfs: http://www.w3.org/2000/01/rdf-schema#
PREFIX georss: http://www.georss.org/georss/
PREFIX dbpprop: http://dbpedia.org/property/
PREFIX skos: http://www.w3.org/2004/02/skos/core#
PREFIX category: http://dbpedia.org/resource/Category:
PREFIX dc: http://purl.org/dc/terms/
PREFIX template: http://dbpedia.org/resource/Template:

SELECT *
WHERE {
    ?subject dbpprop:wikiPageUsesTemplate template:Infobox_airport .
    ?subject dbpprop:type ?type .
    ?subject georss:point ?geo .
    ?subject rdfs:label ?label .
    FILTER (lang(?label) = "en" && REGEX(STR(?type), "Military", "i")) .
}
LIMIT 5

It works fine for what I need, as long as I write separate queries for different structures (I'm fine with that), but there is a problem - it also returns airbases that have long since been abandoned like, for example, old Soviet air bases: https://en.wikipedia.org/wiki/Category:Soviet_Air_Force_bases

Some/most of those are currently not being used (https://en.wikipedia.org/wiki/Liepas_Air_Base). Is there a way I can filter those out? Or is there a different way I could rewrite this query to only get airbases currently in use?

Thanks!

PS - don't worry about the prefixes, I know the URLs are supposed to be wrapped in < ... > but Markdown tries to turn them into links.

predicate-object list does not work

H all;

trying to search some concepts in dbpedia with given strings which may be concepts foaf:name or rdfs:label.

created following query but it is not working.Here is ref.

SELECT ?same
 WHERE { ?same foaf:name  "Be?ikta?"@no;
               rdfs:label  "Besiktas"@en.
         ?same rdf:type &lt;http://dbpedia.org/ontology/SportsTeam&gt;.
       }

This query should give me http://dbpedia.org/resource/Be%C5%9Fikta%C5%9F_J.K. because you can see given resource have a rdfs:label with "Be?ikta?"@no.

I cant see where is the problem. Any idea?

Thanks



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

Information

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