0

I have a CSV file with a list of names in English and Hebrew, I need to get some information on.

The data I need is "name-Hebrew name-English DBpedia-URL date birth place birth dateDeath placeDeath entry_where_found"

for each person, the "entry_where_found" should return if I found the information on DBpedia or wiki data.

I thought of something like this:

PREFIX wd: <http://www.wikidata.org/entity/> 
PREFIX wdt: <http://www.wikidata.org/prop/direct/>
PREFIX dbo: <http://dbpedia.org/ontology/> 

SELECT ?person WHERE { 
  SERVICE <http://dbpedia.org/sparql> {?person a dbo:Person }
  SERVICE <https://query.wikidata.org/sparql> { ?person wdt:P31 wd:Q5 }
}

to query both DBpedia and wikidata, and something like this:

SELECT ?instance_of ?label_he ?label_en ?place_of_birthLabel ?date_of_birth ?place_of_death ?place_of_deathLabel ?date_of_death ?URL WHERE {
  ?instance_of rdfs:label ?label_he.
  ?instance_of rdfs:label ?label_en.
  ?instance_of wdt:P31 wd:Q5.
  ?instance_of wdt:P19 ?place_of_birth.
  ?instance_of wdt:P569 ?date_of_birth.
  ?instance_of wdt:P20 ?place_of_death.
  ?instance_of wdt:P570 ?date_of_death.
  OPTIONAL { ?instance_of wdt:P31 ?record_label. }
  OPTIONAL { ?instance_of wdt:P31 ?instance_of. }
  OPTIONAL { ?instance_of wdt:P2699 ?URL. }
  FILTER(((LANG(?label_he)) = "he") && ((LANG(?label_en)) = "en"))
}

But I don't know how to add a specific name to find each time, and how to combine the query with the first code.

Can someone help? Thank You!

Daniel
  • 21
  • 1
  • 8
  • The name has to be assigned as the literal value of the `rdfs:label` property, e.g. `?instance_of rdfs:label "Albert Einstein"@en`. For non-exact matching, `filter(regex(...))` is the standard SPARQL way to go. Indeed you have to put the triple patterns you want to retrieve inside the `SERVICE` clause for each dataset. – UninformedUser Feb 24 '18 at 13:56
  • Hi, I tried adding the { ?instance_of rdfs:label "Albert Einstein"@en} but I get an error. this is my query https://pastebin.com/FYjTu6bd – Daniel Feb 24 '18 at 14:18
  • Nevermind I got it working with this query: https://pastebin.com/m6zkbUct now how can I use python to send a different name each time? – Daniel Feb 24 '18 at 14:20
  • Do you understand why you got an error? The trailing `.` is missing to denote the end of a triple pattern which is necessary at least if more triple patterns follow. – UninformedUser Feb 24 '18 at 15:33
  • "how can I use python" -> I don't see the difficulty here - just replace the appropriate position of the SPARQL query string by the name. – UninformedUser Feb 24 '18 at 15:34
  • Hi, one last thing, I split my query one for wikidata and one for DBpedia, but my query doesn't work for DBpedia, does it need to have a different syntax? I also tried running it online at http://dbpedia.org/sparql. – Daniel Feb 24 '18 at 15:37
  • 1
    Well, each dataset usually has different schema entities in addition to the common vocabularies like RDF/RDFS/OWL/XSD, thus, different URIs will be used for domain knowledge. Wikidata is **not** DBpedia, – UninformedUser Feb 24 '18 at 18:02

0 Answers0