This should be possible with the Show hint addon of codemirror. If a wd: or wdt: prefix is entered, the completion should search on Wikidata, if wikibase: is entered.
Description
Details
Related Objects
Event Timeline
This should be split into two parts:
One suggestor should handle general SPARQL keywords (and would therefore be reusable in a broad context). Ultimately the first suggestor could automatically read the PREFIX annotations and show them to the user as well. Also variables which have been used already might be suggested if the user types ? or $.
The second suggestor would contain the Wikidata-specific stuff and add autocompletion based on IRIs to wikidata.org and wikiba.se. At first, it makes sense to support only English labels and aliases but it would be nice if the interface language could be changed to be able to search in other languages as well.
Change 246697 had a related patch set uploaded (by Jonas Kress (WMDE)):
Code completion for Wikidata prefixes in SPARQL
Change 246893 had a related patch set uploaded (by JanZerebecki):
Code completion for Wikidata entities in SPARQL
Change 246697 abandoned by JanZerebecki:
Code completion for Wikidata entities in SPARQL
Reason:
Wrong repo, moved to https://gerrit.wikimedia.org/r/#/c/246893/ .
This is pretty cool!
Some UI nitpicks: there is an un-intuitive part that you have to have prefixes defined in order for it to work. It'd be nice to have some feedback or help somewhere about how it should work. As I understand, you have to:
- Have prefixes in the editor window
- Type the prefix (e.g. wd:) and optionally part of the label
- Press Ctrl-Space
- Continue typing the label
It is also not obvious that if you press Ctrl-Space right after prefix, even though nothing visible happens you can continue typing the label and it will start completing. It may be better to show something to indicate completion is now active.
Hey thanks for your feedback!
I also think it would be good to have some user help function to explain how it works.
We decided to parse the prefixes, because someone could rename them and we didn't want to have them hard coded in the hinting plugin.
- Type the prefix (e.g. wd:) and optionally part of the label
wbsearchentites unfortunately doesn't work with empty search strings