Closed falquaddoomi closed 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
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 aPrefixSet
, then makes them available via the/autocomplete
endpoint. The endpoint takes one required parameterprefix
and one optional parameterlimit
(default 20, capped at 100). The result is a list of strings that occur in the corpus that are prefixed byprefix
. 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.