wu :: forums
« wu :: forums - Dictionary lookup that works on multiple values »

Welcome, Guest. Please Login or Register.
May 15th, 2024, 5:13am

RIDDLES SITE WRITE MATH! Home Home Help Help Search Search Members Members Login Login Register Register
   wu :: forums
   riddles
   cs
(Moderators: towr, ThudnBlunder, william wu, Grimbal, SMQ, Eigenray, Icarus)
   Dictionary lookup that works on multiple values
« Previous topic | Next topic »
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print
   Author  Topic: Dictionary lookup that works on multiple values  (Read 918 times)
Ved
Junior Member
**





   


Gender: male
Posts: 53
Dictionary lookup that works on multiple values  
« on: Jul 29th, 2011, 4:26am »
Quote Quote Modify Modify

In a Contact book that has "Name" and "Phone number", I want to implement suggestion based on the entered value on both name as well as phone number.
E.g: contact = "ABC", 123-234-345
  contact = "ABD", 134-345-456
 
So when I type either "A" or "1" it should suggest both the contacts above. In a standard TRIE implementation, we usually use just one field. Is there a way to use both name and number as the TRIE fields ?
IP Logged
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: Dictionary lookup that works on multiple value  
« Reply #1 on: Jul 29th, 2011, 8:35am »
Quote Quote Modify Modify

The answer is probably yes, but I'd just use two tries.
IP Logged

Wikipedia, Google, Mathworld, Integer sequence DB
Ved
Junior Member
**





   


Gender: male
Posts: 53
Re: Dictionary lookup that works on multiple value  
« Reply #2 on: Jul 29th, 2011, 10:05am »
Quote Quote Modify Modify

Thanks Towr. Any suggested approach, reading etc?
IP Logged
towr
wu::riddles Moderator
Uberpuzzler
*****



Some people are average, some are just mean.

   


Gender: male
Posts: 13730
Re: Dictionary lookup that works on multiple value  
« Reply #3 on: Jul 29th, 2011, 12:00pm »
Quote Quote Modify Modify

What programming language are you using? If it has a standard trie library, it's probably easiest to use that.
Abstractly a trie is just a way to store a key-value pair, so you'd have trie_alpha['ABC'] = contact1, trie_alpha['ABD'] = constact2, trie_num['123-234-345'] = contact1, trie_num['123-345-456'] = contact2. So you could even input the same contact under both fields in the same trie if you prefer, but you may want the trie to work slightly differently for names and numbers (such as ignoring -'s when inputting numbers, and perhaps treat it like space in names)
I suppose there's also the question of how you want the suggestions ordered, if you input a number, should suggestions be ordered by number or name? (Or perhaps frequency of use.)
IP Logged

Wikipedia, Google, Mathworld, Integer sequence DB
Ved
Junior Member
**





   


Gender: male
Posts: 53
Re: Dictionary lookup that works on multiple value  
« Reply #4 on: Jul 30th, 2011, 10:58am »
Quote Quote Modify Modify

For this discussion, lets say we do not have a TRIE library in our language.  
In our example lets say I have contact = "GMC","234-456-456"
My problem is somewhat tricky in that if I type "A" or "1" - both contact appear but if I type "2" or "G" only third contact appears. In this case we will have to keep two TRIEs one for name and the other for the phone number. Is that correct ? or is there any optimization
IP Logged
Pages: 1  Reply Reply Notify of replies Notify of replies Send Topic Send Topic Print Print

« Previous topic | Next topic »

Powered by YaBB 1 Gold - SP 1.4!
Forum software copyright © 2000-2004 Yet another Bulletin Board