greenelab / word-lapse

Explore how a word changes over time
https://greenelab.github.io/word-lapse/
Other
6 stars 3 forks source link

Autocomplete Support (API side) #28

Closed falquaddoomi closed 2 years ago

falquaddoomi commented 2 years ago

This PR depends on https://github.com/greenelab/word-lapse-models/pull/4 being merged before it's integrated. The PR adds a library, pygtrie, which implements various tries. We're using the PrefixSet variant here, since all we need to do is query for elements matching a prefix, not store values in the nodes of the trie.

At initialization, the server looks for a file called ./data/full_vocab.txt containing a newline-delimited list of words in the corpus. It inserts the contents into a PrefixSet, then makes them available via the /autocomplete endpoint. The endpoint takes one required parameter prefix and one optional parameter limit (default 20, capped at 100). The result is a list of strings that occur in the corpus that are prefixed by prefix. Note that prefixes shorter than three characters will simply return the prefix itself in a list.

Partially addresses #27 -- there's probably another issue that needs to be created for frontend integration.

netlify[bot] commented 2 years ago

✔️ Deploy Preview for word-lapse canceled.

🔨 Explore the source changes: 4ef1789ea545d4ac0e4741fbe881d31d5bf1f34a

🔍 Inspect the deploy log: https://app.netlify.com/sites/word-lapse/deploys/62205b19a834be000898d8a9