Skip to content
This repository has been archived by the owner on May 6, 2018. It is now read-only.

ouisharelabs/wikidata-autocomplete

Repository files navigation

wikidata-autocomplete

a little experiment using wikidata API search to fill an html input. Doesn't work very well as such: it does search but can't suggest autocomplete. For instance, if I'm look for "Les Misérables", it will successivelly do the following requests:

"https://www.wikidata.org/w/api.php?action=wbsearchentities&language=fr&format=json&search=Les"
"https://www.wikidata.org/w/api.php?action=wbsearchentities&language=fr&format=json&search=Les M"
"https://www.wikidata.org/w/api.php?action=wbsearchentities&language=fr&format=json&search=Les Mi"
"https://www.wikidata.org/w/api.php?action=wbsearchentities&language=fr&format=json&search=Les Mis"
"https://www.wikidata.org/w/api.php?action=wbsearchentities&language=fr&format=json&search=Les Misé"
"https://www.wikidata.org/w/api.php?action=wbsearchentities&language=fr&format=json&search=Les Misér"
"https://www.wikidata.org/w/api.php?action=wbsearchentities&language=fr&format=json&search=Les Miséra"
"https://www.wikidata.org/w/api.php?action=wbsearchentities&language=fr&format=json&search=Les Misérab"
"https://www.wikidata.org/w/api.php?action=wbsearchentities&language=fr&format=json&search=Les Misérabl"
"https://www.wikidata.org/w/api.php?action=wbsearchentities&language=fr&format=json&search=Les Misérable"
"https://www.wikidata.org/w/api.php?action=wbsearchentities&language=fr&format=json&search=Les Misérables"

Then it appends all the results to jQuery Autocomplete availableTags array.

not very efficient, so I tried to limit the queries with a timeout

Setup

git clone git@github.com:ouisharelabs/wikidata-autocomplete.git
npm install
coffee ./cors-proxy.coffee 3001

this last command starts a proxy to allow queries to wikidata from the browser (could probably be done server-side, but it seemed easier this way)

then you can start a minimalist server with python -m SimpleHTTPServer in this directory and go to http://localhost:8000/autocomplete.html Would do something cleaner if this gets somewhere.

Documentation

About

autocomplete based on wikidata entities

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published