Page MenuHomePhabricator

Improve code examples of the Wikidata Query UI
Open, MediumPublic

Description

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:

code.png (294×809 px, 11 KB)

Java.png (730×1 px, 98 KB)

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

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
Restricted Application added a subscriber: Aklapper. · View Herald Transcript
abian renamed this task from Improve code examples of the Query UI to Improve code examples of the Wikidata Query UI.Nov 24 2018, 9:54 PM
abian updated the task description. (Show Details)

Change 476002 had a related patch set uploaded (by Rafidaslam; owner: Rafid Aslam):
[wikidata/query/gui@master] Improve code examples for Java and Python

https://gerrit.wikimedia.org/r/476002

Change 476002 merged by jenkins-bot:
[wikidata/query/gui@master] Improve code examples for Java and Python

https://gerrit.wikimedia.org/r/476002

Change 476049 had a related patch set uploaded (by WDQSGuiBuilder; owner: WDQSGuiBuilder):
[wikidata/query/gui-deploy@production] Merging from c4546eaa9dc6460d59e5307cb7f9830c917b7bb4:

https://gerrit.wikimedia.org/r/476049

abian updated the task description. (Show Details)
abian updated the task description. (Show Details)
rafidaslam added a subscriber: rafidaslam.

Change 476049 merged by Smalyshev:
[wikidata/query/gui-deploy@production] Merging from c4546eaa9dc6460d59e5307cb7f9830c917b7bb4:

https://gerrit.wikimedia.org/r/476049

Change 477783 had a related patch set uploaded (by Michael Große; owner: Michael Große):
[wikidata/query/gui@master] Improve PHP code example

https://gerrit.wikimedia.org/r/477783

Change 477808 had a related patch set uploaded (by Michael Große; owner: Michael Große):
[wikidata/query/gui@master] Improve JS(modern) code example

https://gerrit.wikimedia.org/r/477808

Addshore triaged this task as Medium priority.Dec 6 2018, 11:02 AM

Change 477783 merged by jenkins-bot:
[wikidata/query/gui@master] Improve PHP code example

https://gerrit.wikimedia.org/r/477783

Change 477808 merged by jenkins-bot:
[wikidata/query/gui@master] Improve JS code examples

https://gerrit.wikimedia.org/r/477808

Michael added a subscriber: Michael.

Change 480575 had a related patch set uploaded (by Ladsgroup; owner: Ladsgroup):
[wikidata/query/gui@master] Improve pywikibot example

https://gerrit.wikimedia.org/r/480575

Change 480575 merged by jenkins-bot:
[wikidata/query/gui@master] Improve pywikibot example

https://gerrit.wikimedia.org/r/480575

Change 480673 had a related patch set uploaded (by WDQSGuiBuilder; owner: WDQSGuiBuilder):
[wikidata/query/gui-deploy@production] Merging from b54c34b48cfb89a0daafc25a18f43dc3a7fb1d35:

https://gerrit.wikimedia.org/r/480673

@Lydia_Pintscher i'm not sure this was ever picked up on the campsite with the intention of us doing the work, just for us to review? so perhaps we can remove it now there is nothing to review?

Yes this was for review. If there is nothing left to review we can remove it from camp.

@mpopov, maybe you would like to write the R code snippet using your own package WikidataQueryServiceR?

Change 492730 had a related patch set uploaded (by Lucas Werkmeister (WMDE); owner: Lucas Werkmeister (WMDE)):
[wikidata/query/gui@master] Fix pywikibot example

https://gerrit.wikimedia.org/r/492730

Change 492730 merged by jenkins-bot:
[wikidata/query/gui@master] Fix pywikibot example

https://gerrit.wikimedia.org/r/492730

Change 492980 had a related patch set uploaded (by WDQSGuiBuilder; owner: WDQSGuiBuilder):
[wikidata/query/gui-deploy@production] Merging from 181b14abc3d498a0afe5e6d4cea5471a073cae66:

https://gerrit.wikimedia.org/r/492980

Change 492980 merged by Smalyshev:
[wikidata/query/gui-deploy@production] Merging from 181b14abc3d498a0afe5e6d4cea5471a073cae66:

https://gerrit.wikimedia.org/r/492980

Partly done, but not actively being worked on, so moved back to ready to go from doing