0

I have a question I need to build a single query to DBpedia such that, If I give any one of these as input like a City name or a person name or a Institute name or a Instrument name can I get its abstract as a output??? For instance, New York- New York is a state in the Northeastern and Mid-Atlantic regions of the United States...... Mars- Mars is the fourth planet from the Sun and the second smallest planet in the Solar System.... Michael Jackson- Michael Joseph Jackson was an American singer, songwriter, dancer, and actor......

I have tried but its not working for all.

 SELECT ?abstract WHERE { 
 <http://dbpedia.org/resource/New_York> 
 <http://dbpedia.org/ontology/abstract> 
 ?abstract
 FILTER langMatches(lang(?abstract), "en")
 }

1 Answers1

3

If you intend to get the abstract for multiple things, supply those multiple things within a VALUES block. I found that matching by ?name worked sufficiently well for name-based searches.

SELECT DISTINCT ?abstract WHERE { 
  [ rdfs:label ?name
  ; dbpedia-owl:abstract ?abstract
  ] .
  FILTER langMatches(lang(?abstract),"en")
  VALUES ?name { "New York"@en }
}
LIMIT 10
Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
Rob Hall
  • 2,693
  • 16
  • 22
  • But when I write VALUES ?name { "New York" "Car"@en } its not giving any output. – user2022416 Sep 23 '14 at 15:17
  • If I add this query in java at line: VALUES ?name { "New York"@en } its giving error: Syntax error, insert ";" to complete LocalVariableDeclarationStatement – user2022416 Sep 23 '14 at 15:25
  • In java can I declare a String Value = "New York" and declare this String in Sparql query??? – user2022416 Sep 24 '14 at 00:07
  • Yes, I'd use [`ParameteriedSparqlString`](https://jena.apache.org/documentation/query/parameterized-sparql-strings.html) to set values before evaluating the query if you can't use a `values` block. Regarding your first comment, you'd want to say `VALUES ?name { "New York"@en "Car"@en } .` – Rob Hall Sep 28 '14 at 22:12