-1

I try to get all POIs from a special longitude and latitude.

Can you give me a hint to get better results? I now get subjects like :Germany and :M-Bahn in my result set.

Here is my java code:

public class DBPedia_SparqSql {

  /**
   * @param args
   */
  public static void main(String[] args) {
    // TODO Auto-generated method stub
    float YOUR_LONG = 13.380834f;
    float YOUR_LAT = 52.516388f;
    float radius = 0.01f;
    String sparqlQueryString1= "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#> "+
    "PREFIX geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> "+
    "PREFIX onto: <http://dbpedia.org/ontology/> " +
    "PREFIX dcterms: <http://purl.org/dc/terms/> "+
    "SELECT DISTINCT ?s ?sub ?long ?lat WHERE {"+
    "?s a onto:Place . "+
    "?s geo:lat ?lat . "+
    "?s geo:long ?long . " +
    "?s dcterms:subject ?sub "+
    " FILTER ( ?long > "+(YOUR_LONG-radius)+"&& ?long < "+(YOUR_LONG+radius)+" && ?lat > "+(YOUR_LAT-radius)+" && ?lat < "+(YOUR_LAT+radius)+")}"+
    "LIMIT 200";
    System.out.println(sparqlQueryString1);

    Query query = QueryFactory.create(sparqlQueryString1);
    QueryExecution qexec = QueryExecutionFactory.sparqlService("http://dbpedia.org/sparql", query);

    ResultSet results = qexec.execSelect();
    ResultSetFormatter.out(System.out, results, query);       

    qexec.close() ;
  }

}
Ben Companjen
  • 1,417
  • 10
  • 24
Sesigl
  • 600
  • 4
  • 17

1 Answers1

1

It depends a bit on what you mean with "better". What you are looking for is a discriminating feature, some property that "good" results do have, and "bad" results don't (or the other way around).

A good way to find out what properties to query for is to just go the DBPedia resource page for a particular subject, and see what's there. The page for Germany shows everything DBPedia knows about that topic: that it is a country, what its population size is, etc.

A good property to look at is the rdf:type property. See if the results that you do want back share some value for that, and then add that to your query. But you can use other (combinations of) properties as well. I can't tell you what those properties or values should be, only you know your own use case.

Jeen Broekstra
  • 21,642
  • 4
  • 51
  • 73