Open eklem opened 4 years ago
The word array could just be stored in a file or in indexedDB and read to memory when page is loaded.
Just do the indexedDB example. What's needed:
Do this after stopwords are removed, so less processing. Show a slider for fuzzy search on/off with the extra words searched on?
So, search-index
got all I need.
Did this in the browser console in the demo:
db.DICTIONARY().then(resultsDir)
And got all the words in the index back out again.
This means you do this first time every time the app/page loads and populate an array. It will be in memory until the page is reloaded, then you need to do the DICTIONARY stuff once more. So check if exists, if not do it.
Then loop through each word in the query and do a Levenshtein if-check for each word in the dictionary.
Should make sure all words in the index are lowercase so the dictionary array is not that big.
https://en.wikipedia.org/wiki/Levenshtein_distance
Could use
leven
. First, when indexing, make a separate array of all words used (or see if any way possible to get this from search-index). Then, when searching, do a Levenshtein distance on 1 or 2 and do an OR-search on words you get back.