Is there a quick and easy to lookup just the Wikipedia gloss text in DBpedia for a specific URI with the DBpedia JSON API?
e.g. I can get all triples DBpedia has on cats by downloading http://dbpedia.org/data/Cat.json, but all I want are the triples with {"type" : "literal" ...}
. Can I get this without downloading and parsing the entire JSON output? The JSON API doesn't appear to support any type of filtering, and I can't find any docs.
It sounds like what you're looking for is all the triples of the form [dbpedia:Cat ?p ?o] where ?o is a literal. You can get those with a SPARQL CONSTRUCT query against the public DBpedia endpoint and requesting results in RDF/JSON.
construct where {
dbpedia:Cat ?p ?o
filter isLiteral(?o)
}
Construct queries are part of the SPARQL standard, and are described in 16.2 CONSTRUCT. If you're using the sparql-client for Python (there's no language tag on this question though, so there's no reason to assume that the general reader will be), note that its documentation says:
sparql-client is a SPARQL query library that performs SELECT and ASK queries against a SPARQL endpoint via HTTP.
Since this particular client doesn't support CONSTRUCT queries, you'll need to use a SELECT query instead. You can use:
select ?p ?o {
dbpedia:Cat ?p ?o
filter isLiteral(?o)
}
The resulting JSON isn't quite the same form, but it's still pretty regular, and you'll be able to process it without much trouble:
{ "head": { "link": [], "vars": ["p", "o"] },
"results": { "distinct": false, "ordered": true, "bindings": [
{ "p": { "type": "uri", "value": "http://dbpedia.org/ontology/abstract" } , "o": { "type": "literal", "xml:lang": "nl", "value": "De kat of huiskat (Felis catus) is een van de oudste huisdieren van de mens. De gedomesticeerde kat behoort tot de familie der katachtigen (Felidae). De oude soortnaam was Felis domesticus, tegenwoordig is deze vervangen door Felis catus. Eind 2009 waren in Nederland ongeveer 3,6 miljoen katten aanwezig." }},
…
{ "p": { "type": "uri", "value": "http://dbpedia.org/ontology/conservationStatus" } , "o": { "type": "literal", "xml:lang": "en", "value": "DOM" }},
{ "p": { "type": "uri", "value": "http://dbpedia.org/ontology/synonym" } , "o": { "type": "literal", "xml:lang": "en", "value": "Felis catus domestica (invalid junior synonym)" }},
{ "p": { "type": "uri", "value": "http://dbpedia.org/ontology/synonym" } , "o": { "type": "literal", "xml:lang": "en", "value": "Felis silvestris catus (subjective synonym)" }},
{ "p": { "type": "uri", "value": "http://dbpedia.org/ontology/wikiPageID" } , "o": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "6678" }},
{ "p": { "type": "uri", "value": "http://dbpedia.org/ontology/wikiPageRevisionID" } , "o": { "type": "typed-literal", "datatype": "http://www.w3.org/2001/XMLSchema#integer", "value": "547667240" }},
{ "p": { "type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#label" } , "o": { "type": "literal", "xml:lang": "zh", "value": "\u732B" }},
{ "p": { "type": "uri", "value": "http://www.w3.org/2000/01/rdf-schema#label" } , "o": { "type": "literal", "xml:lang": "de", "value": "Hauskatze" }},
…