As a user I want to easily reuse data from Wikidata by copying code snippets from query.wikidata.org in my preferred languages.
Problem: Code examples provided by the Wikidata Query UI (query.wikidata.org) are mostly poor. Some of the snippets are incomplete or have typos.
Screenshots:
Example: The Java snippet is dirty and contains mistakes which prevent an application from being compiled...
for (HashMap value : (ArrayList>) rs.get("result").get("rows")) {
Acceptance criteria:
For all the programming languages that are considered:
- The code snippet can be properly executed without requiring any change on it and returns or prints the results of the requested query.
- Tasks of data retrieval are encapsulated in a function/procedure/method and there isn't any data exchange with Wikidata outside that function/procedure/method.
- The code is understandable and consistently formatted (indentation, spaces, line breaks, etc.).
- At least the query and the URL endpoint are easily configurable (e.g., by directly assigning each value to a variable).
- Retrieved data are stored in an iterable or navigable data structure (e.g., an array).
To do:
- PHP
- JavaScript (jQuery)
- JavaScript (modern)
- Java
- Perl
- Python
- Python (Pywikibot)
- Ruby
- R
- Matlab