WikidataQueryServiceR icon indicating copy to clipboard operation
WikidataQueryServiceR copied to clipboard

query_wikidata may drop results

Open matdillen opened this issue 6 years ago • 0 comments

While using this package, one of my queries kept returning a different and way too low number of results. The query in question:

SELECT ?item ?itemLabel ?bhl_id ?orcid ?viaf ?isni WHERE {
  ?item wdt:P4081 ?bhl_id. #BHL creator
  SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en" } 
  OPTIONAL { ?item wdt:P496 ?orcid .}
  OPTIONAL { ?item wdt:P214 ?viaf .}
  OPTIONAL { ?item wdt:P213 ?isni .}
}

As of now, this should return 27.225 results, but I only got some number between 7.000 and 10.000 each time. Upon closer inspection, it seems to cut off every time it reaches an item with a ÿ character in its label. So I think it's an encoding problem during the content extraction. I am running this on a Windows 10 machine, don't know if that may play a role.

When using the following function:

querki <- function(query,h="text/csv") {
  require(httr)
  response <- httr::GET(url = "https://query.wikidata.org/sparql", 
                        query = list(query = query),
                        httr::add_headers(Accept = h))
  return(httr::content(response))
}

I do get all results.

matdillen avatar Oct 04 '19 10:10 matdillen