How to display list using SPARQL - sql

I am trying to show the list of Charities from this page - http://dbpedia.org/page/Category:Charitable_organizations
The list is in is dct:subject of property, I have made a query but it doesn't work.
QUERY
WHERE {
?s dbo:type dbr:Charitable_organization .
}
I do kind of know how to use SPARQL with DBPEDIA but am unsure how to use the dct:subject part and display the `dbr:'
Using the site- http://dbpedia.org/sparql to execute queries. So any help on how I can show the list of charities from that website? Thanks for reading.

Your query should be:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX type: <http://dbpedia.org/class/yago/>
PREFIX prop: <http://dbpedia.org/property/>
PREFIX dbr: <http://dbpedia.org/resource/>
## Added ##
PREFIX dbo: <http://dbpedia.org/ontology/>
SELECT *
WHERE {
?s dbo:type dbr:Charitable_organization .
}
Links
Live Results Page Link.
Live Query Definition Link.

Related

freetext search in dbpedia

I want to use freetext search against the dbpedia and I'm trying the query I found on the W3C website: https://www.w3.org/2009/Talks/0615-qbe/
If I try the query WITHOUT the bif: prefix by commenting it out I get the error shown below the query:
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX type: <http://dbpedia.org/class/yago/>
PREFIX prop: <http://dbpedia.org/property/>
# PREFIX bif: <http://www.openlinksw.com/schemas/bif#>
SELECT ?lbl ?est
WHERE {
?country rdfs:label ?lbl .
FILTER(bif:contains(?lbl, "Republic")) .
?country a type:Country108544813 ;
prop:establishedDate ?est .
FILTER(?est < "1920-01-01"^^xsd:date) .
}
Error: Line 9, Parse error: namespace mapping for "bif" not defined
when expanding QName "bif:contains".
[condition type: sparql-lexer-error-namespace-mapping-not-defined]
well: that makes sense, you do need to define your namespace. So let me do the same query again using the bif: prefix that I found on the Virtuoso website (and various other places)
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX type: <http://dbpedia.org/class/yago/>
PREFIX prop: <http://dbpedia.org/property/>
PREFIX bif: <http://www.openlinksw.com/schemas/bif#>
SELECT ?lbl ?est
WHERE {
?country rdfs:label ?lbl .
FILTER(bif:contains(?lbl, "Republic")) .
?country a type:Country108544813 ;
prop:establishedDate ?est .
FILTER(?est < "1920-01-01"^^xsd:date) .
}
Now I get a different error: it seems that the bif: namespace is a protected name by Virtuoso
So it seems I cannot live with bif: or without :bif. Has anyone seen this error before? Thanks.
Btw: I really don't care that much about bif: What I really want is to do freetext queries against dbpedia. So any alternative is welcome. YES: there are earlier questions on SO about this but note that each of those answers contain bif: as well.
Added later: so just to be sure I changed bif: into bof: and now I get a new error that shows that contains no longer is a valid operator. See below. So anyway: I guess the only thing I care about from here on is: how do you do freetext queries against dbpedia :-)
bif: is a Virtuoso built-in, for "built-in function".
You're going through some sort of SPARQL pre-parser, not directly against the SPARQL endpoint, so you do need to define the prefix in your query. Most such pre-parsers will do the right thing if you just --
PREFIX bif: <bif:>
Alternatively, you can change your query from using the bif:contains function --
FILTER(bif:contains(?lbl, "Republic"))
-- to use SPARQL regex --
FILTER regex(?lbl, "Republic")

SPARQL Query returning nothing from fr.dbpedia.org

I am using the following SPARQL query to retrieve the IATA code for Laker Airways.
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dbo: <http://dbpedia.org/ontology/>
select ?airline ?iata where {
?airline a dbo:Airline.
?airline rdfs:label "Laker Airways"#en.
OPTIONAL {?airline dbo:iataAirlineCode ?iata.}
}
This works against http://dbpedia.org/sparql/ but not against http://fr.dbpedia.org/sparql/.
What am I doing wrong?
Your SPARQL works against the English language endpoint
So, use the English endpoint; it has different data from the French one.

SPARQL query not returning any data

I am new to RDF, so it will be very nice if you can help me with this!
I am trying to query the subject of pickles called "Umeboshi"(It is japanese pickles) as follows:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX type: <http://dbpedia.org/class/yago/>
PREFIX prop: <http://dbpedia.org/property/>
PREFIX onto: <http://dbpedia.org/ontology/>
SELECT ?label ?subject
WHERE {
?Thing
rdfs:label ?label;
prop:subject?subject.
FILTER (?label = "Umeboshi")
}
This query doesn't give me any data.
As I don't know where to find available properties I am referring to the Umeboshi page on dbpedia http://live.dbpedia.org/page/Umeboshi.
Thank you very much for your help!
Two things I found:
In the page you give, the label is given in English, but in your query you omit the language.
subject has a different namespace. It is a dcterm concept and not a dbpedia property.
This leads to the following, changed query, which results in three bindings:
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX dct: <http://purl.org/dc/terms/>
SELECT ?label ?subject
WHERE {
?Thing
rdfs:label ?label;
dct:subject ?subject.
FILTER (?label = "Umeboshi"#en)
}

Sparql result not containing specified property included in results

I have this query
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
PREFIX dbpedia: <http://dbpedia.org/>
PREFIX dbpedia_property: <http://dbpedia.org/property/>
PREFIX dbpedia_ontology: <http://dbpedia.org/ontology/>
PREFIX yago: <http://dbpedia.org/class/yago/>
PREFIX schema: <http://schema.org/>
SELECT * WHERE
{
{
SELECT ?school
WHERE
{
?school rdf:type yago:EducationalInstitution108276342 .
FILTER ( contains(str(?school), "Australia") )
}
ORDER BY ?school
}
}
Don't mind the extra brackets as this is part of a larger query.
What I want to know is why thi http://dbpedia.org/page/Academic_structure_of_the_Australian_National_University is included in the results since I specify rdf:type yago:EducationalInstitution108276342. This property is not included in the resource page. I'm using this endpoint: http://dbpedia.org/sparql
Looks like a bug in the Pubby Web interface or in the query that is used to get the data that will be shown.
The query
SELECT * WHERE{
<http://dbpedia.org/resource/Academic_Structure_of_the_Australian_National_University> ?p ?o
}
returns the necessary rdf:type statement.
The other strange thing is that even a SPARQL DESCRIBE query does not return the rdd:type triples:
DESCRIBE <http://dbpedia.org/resource/Academic_Structure_of_the_Australian_National_University>
Although DESCIBE is not really defined in the specs, a user would expect those triples for sure. And maybe this kind of query is used to retrieve the data for the Web pages of resources.

How to access permanently removed pages using SPARQL?

I am facing a problem in using SPARQL with DBPedia.
for example if I call this link directly
http://dbpedia.org/resource/Venice,_Italy
I see a 301 redirect code to
http://dbpedia.org/page/Venice
but if i try to call Venice,_Italy resorce using SPARQL I get nothing back.
define input:default-graph-uri <http://dbpedia.org>
PREFIX ontology: <http://dbpedia.org/ontology/>
PREFIX property: <http://dbpedia.org/property/>
PREFIX resource: <http://dbpedia.org/resource/>
PREFIX position:<http://www.w3.org/2003/01/geo/wgs84_pos#>
SELECT DISTINCT ?Abstract ?ThumbnailURL WHERE
{ <http://dbpedia.org/resource/Venice,_Italy> ontology:abstract ?Abstract. <http://dbpedia.org/resource/Venice,_Italy> ontology:thumbnail ?ThumbnailURL.
FILTER (lang(?Abstract)="en")}
You can leverage the ontology:wikiPageRedirects property to ensure your query actually gets an answer by traversing the redirect in your query e.g.
PREFIX ontology: <http://dbpedia.org/ontology/>
PREFIX property: <http://dbpedia.org/property/>
PREFIX resource: <http://dbpedia.org/resource/>
PREFIX position:<http://www.w3.org/2003/01/geo/wgs84_pos#>
SELECT DISTINCT ?Abstract ?ThumbnailURL
WHERE
{
<http://dbpedia.org/resource/Venice,_Italy> ontology:wikiPageRedirects ?page .
?page ontology:abstract ?Abstract.
?page ontology:thumbnail ?ThumbnailURL.
FILTER (lang(?Abstract)="en")
}