I was added to the Github Copilot preview in the past days, and the first thing I tested out was code suggestions around Wikidata. Copilot allows you

A first look at Wikidata through Github Copilot

submited by
Style Pass
2021-07-11 23:30:09

I was added to the Github Copilot preview in the past days, and the first thing I tested out was code suggestions around Wikidata.

Copilot allows you to start writing code, and have a model trained on public Github code suggest block of code that you might want to use.

More targeted toward Wikidata, if you start defining a function called whatIsWikidata then it might suggest return "Wikidata";

Of 10 suggestions, 6 used XMLHttpRequest, 3 used jquery, and the final suggestion was fairly useless for what I was aiming for.

When paired with the xmlhttprequest package for node and a quick function call and console.log call the first example actually works, returning JSON that includes the entity requested.

Interestingly Copilot here chose to use Special:EntityData instead of the wbgetentities action API module for Wikidata. The function also does not unwrap the result to only provide the single entity. This is the request that is made.

The second solution correctly retrieves and decodes a single entity JSON using onload for the request. Adding a quick console.log in before the return within onload shows the request being correctly made.

Leave a Comment