Robert B.
June 12, 2017
Composing text messages got easier because of help of n-grams which provide the ability to predict the next set of possible words as a text message is typed.
This application is comprised of multiple n-grams, there is a set of 2-gram, 3-gram, 4-gram and 5-grams, each n-gram has been sorted by frequency and has probability assigned to each element of the n-mgram.
The n-grams are created based on english data files downloaded from the Swiftkey site.
The application takes any word or phrase as input and provides a list of possible next words based on the n-gram match and the frequency from highest to lowest. An input slider provides the ability to set the maximum number of words possible to predict.
The prediction algorithn can start predicting the next word, right after the first word is typed and when the user stops typing the prediction algorithm automatically will suggest the next word(s). For sentences longer than 4 words the algorithm will pick the last 4 words of the sentence and will try to predict the next word. The send button simulates the action of sending a text message after is typed.
A data table on the right will display a list of the sent messages. The table will display up to 5 mesage per page. The data table allows to search or filter messages based on specific provided pattern.
On initial startup of the application multiple n-gram files are uploaded in memory. The prediction algorightm is also loaded along with any other depending function that is invoked by the prediction algorithm.
The prediction algorithm is invoked when the user types the text message, based on the length of the message the prediction algorithm will do a lookup search on the matching ngram, if there is no matching ngram the algorithm will use the back off method to do a search on the next shorter n-gram and so forth.
If the initial text message contains more than 4 words, the algorithm will use only the last four words and will try to predict the next word based on the 5-gram.
The following screenshot depicts the versatility of this application.
Link to Compose Text Messages App
Note: Depending on your machine the application could take 20 to 30secs to load.
Thank You.