Python trie implementation - efficiently search trie based on prefixes

@adhamfaisal

Okay, I think I have it here.

This clone does the following:

  • allows you to build a trie from a list of strings (see the build_trie function)
  • saves the trie in a DataTable as JSON (and returns it as a dictionary)
  • autocomplete search terms using the precomputed trie (see Module1)

I did not use the code above exactly, but mine is similar (e.g., there are no classes).

You will have to find a way of getting your large list of words into the build_trie function. However, that should be easy, as you can just run it on your computer and paste it into the DataTable if you want.

Once you have your trie saved in the DataTable, you never have to compute it again.

Here you can see a precomputed trie being searched and a new one being built.

clone:
https://anvil.works/build#clone:A7T6NRQIS5RDKXGK=3T6LAP6WSNC7CLKBSBL5AK4O

Let me know if this helps.

3 Likes