Thursday, October 18, 2012

Implement Mobile T9 using TRIE


T9's objective is to make it easier to type text messages. It allows words to be entered by a single keypress for each letter. T9's objective is to make it easier to type text messages. It allows words to be entered by a single keypress for each letter.  For instance, in English, 4663 matches "good", "home", "gone", "hood", etc. 

This program takes in a dictionary file as input, reads it and creates a Ternary Search Trie (TST). Once the Trie is created, any word can be searched. The matching words for a given sequence are stored in ascending order (instead of word ranking). This code can be modified to accomplish word ranking and machine learning. 

The above code can be implemented with HashMap. However hashing does not provide efficient searching. 
For the purpose of benchmarking, I have enabled the runtime stats in this class. I have tested with 3 types of dictionaries. The biggest dictionary I could get hold off was containing 3.7 million words. The program currently accepts only alphabets. 

Solution

3 comments:

  1. hey nice 1 but i ve a doubt. how do u decide on left right middle refrences. from my understanding, these point to respective chars like 2->a,b,c and so on. but what does node.left or node.right means? Please explain..

    ReplyDelete
  2. Can you please attach the dictionary file to test , Will appreciate that?

    ReplyDelete

UA-36403895-1