I'm querying DBpedia for the title and abstract of a place-name in English only. The query works, but it returns the results in seven languages.
This is my query:
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
SELECT ?wikipedia_data_field_name ?wikipedia_data_field_abstract
WHERE {
?wikipedia_data foaf:name "Ballyhaunis"@en; foaf:name
?wikipedia_data_field_name; dbpedia-owl:abstract ?wikipedia_data_field_abstract.
}
SPARQL result
I tried to add a filter using various permutations of
FILTER (LANGMATCHES(LANG(?abstract), 'en'))
but then the query returned no results. I can't see any other property in the corresponding page (http://dbpedia.org/page/Ballyhaunis) that I might be able to filter by. How can I restrict the results to show only the English abstract?
With thanks to @Joshua Taylor for advice on the correct way to compare language tags, here is a better answer that works.
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbpedia-owl: <http://dbpedia.org/ontology/>
SELECT ?wikipedia_data_field_name ?wikipedia_data_field_abstract
WHERE {
?wikipedia_data foaf:name "Ballyhaunis"@en; foaf:name
?wikipedia_data_field_name; dbpedia-owl:abstract ?wikipedia_data_field_abstract.
FILTER langMatches(lang(?wikipedia_data_field_abstract),'en')
}
SPARQL result
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With