Reputation: 199215
I'm wondering if anyone has good resources to read or code to experiment for "autcomplete"
I would like to know what's the theory behind autocompletion, where to start what are the commonn mistakes etc.
I found fascinating the way products like Enso, Launchy, Google chrome and even tcsh perform their auto complete, I started my self just for curiosity some sample code and I got to the conclusion this must be a field widely explored before.
I would appreciate if someone shares any good technical resource on how to implement this.
Thanks in advance.
Upvotes: 15
Views: 7957
Reputation: 659
It is an open problem and there are dozen of strategies based on situations. based on my knowledge, I list a short highlights of some of well known Auto Completion strategies and their corresponding data structures. also I tried to summarizing their major pros and cons related to Auto Completion problem.
Brute Force :
Directed Acyclic Graph (DAG) :
Trie has space problem so other data structures main goal is reducing the space complexity. Directed Acyclic Graph (DAG) is one of the options. by using DAG you can merge all similar subpath to only one. as a result much of space will be reserved.
fast-autocomplete repository is in this area which uses Directed Word Graph (DWG) and Levenshtein Edit Distance.
Some other Tree options :
On each state(or Node) there is a search problem. linear search is the worst case option so most strategies improved their search time by using either sorting( O(nlog(n) ) and then using Binary search( O(log(n)) ) or using a hashtable ( O(1), fast but has more space complexity). encountering so many trade-off dilemmas, other tree data structure variants like Radix Tree, Suffix Tree, Suggest Tree and Merkle Tree may come useful.
Prioritizig Offers : Markov Chain can be used to prioritize next states. it stores connection probabilities which leads to more accurate results.
Artificial Intelligence strategies:
Long short term memory (LSTM ) :
there are so many useful Machine Learning and Deep Learning strategies. a good strategy, you can consider Auto Completion as a time series problem so you can use some models like LSTM.
Transformers :
The last but not least, I recommend Transformer models. currently they are game changers. a great Transformer based language model is Google BERT. it is highly promising on predicting future sequences.
I also recommend, before starting your Auto Completion project using transformers, please take a look at python_autocomplete repository which uses Transformers and LSTMs to learn Python source code.
Good luck!
Upvotes: 1
Reputation: 6436
Autocomplete is usually implemented using one of the following:
A couple of papers about the subject:
Take a look at completely, a Java autocomplete library.
Upvotes: 0
Reputation: 8471
Check out this blog on implementing autocomplete using GWT:
http://jroller.com/glongman/entry/gwt_autocompleter
But I would recommend you first start with something very simple on your own to grasp how the implementation is done. I'd start with a Trie, maybe even stored completely on the client, then progress to optimizing with server queries if you think they're necessary.
Upvotes: 2
Reputation: 13121
Upvotes: 12