Closed nichtich closed 8 years ago
what is the query that generated this result? so far, the value parsing is based on the type (but is probably incomplete): this could be completed (or replaced?) by a switch on the datatype
Such results can also come from SPARQL functions for instance COUNT:
$ cat query
SELECT (COUNT(?p) AS ?c) WHERE { wd:Q42 ?p ?v }
$ wdsparql query
{
"head" : {
"vars" : [ "c" ]
},
"results" : {
"bindings" : [ {
"c" : {
"datatype" : "http://www.w3.org/2001/XMLSchema#integer",
"type" : "literal",
"value" : "432"
}
} ]
}
}
$ wdsparql --simplify query
[
"432"
]
Looking at https://www.mediawiki.org/wiki/Wikibase/Indexing/RDF_Dump_Format I found data types xsd:decimal, xsd:integer, and xsd:dateTime (the latter not numeric) to be expected from Wikidata values. For instance this will get you a xsd:decmial:
SELECT ?e WHERE { wd:Q193 wdt:P1096 ?e }
Using other SPARQL features one can also get xsd:float, xsd:double, and (!) xsd:boolean, for instance:
SELECT (bound(?y) AS ?exists) WHERE {
wd:Q1 wdt:P580 ?x . OPTIONAL { wd:Q1 wdt:P99999 ?y }
} LIMIT 1
I will submit a pull request do handle these cases!
solved by 8d340da
should be simplified as
instead of
I don't know whether there can be other numeric types such as xsd:float (?)