Creating a “spell check” that checks against a database with a reasonable runtime

后端 未结 6 1670
Happy的楠姐
Happy的楠姐 2021-01-31 05:22

I\'m not asking about implementing the spell check algorithm itself. I have a database that contains hundreds of thousands of records. What I am looking to do is checking a user

6条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-31 05:33

    You will need to structure your data differently than a database can. Build a custom search tree, with all dictionary data needed, on the client. Although memory might become a problem if the dictionary is extremely big, the search itself will be very fast. O(nlogn) if I recall correctly.

    Have a look at BK-Trees

    Also, instead of using the Hamming distance, consider the Levenshtein distance

提交回复
热议问题