rkapsi / patricia-trie

Practical Algorithm to Retrieve Information Coded in Alphanumeric (PATRICIA)

Home Page:http://code.google.com/p/patricia-trie

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Patricia trie and search

mapo80 opened this issue · comments

Hi, thanks for your Patricia Trie implementation, it's perfect. I've a question for you.
I have to implement a business address book that contains 30000 names(firstname and lastname). I have to implement a search not only by insert firstname+lastname but also by lastname+firstname. To implement this type of search I'm inserting in the patricia trie two records, the first with value "firstname surname" the second with "surname firstname", I think this could a redundant double entry. Is there a better way to implement this search?
Consider that second value of the trie (trie<string, list>) should be a List countaining all the people with that name.

I hope I was clear. Thanks for your attention.

Bye bye.

Hey, there isn't much you can do to optimize it further. Maybe a Trie<String, Trie<String, List<T>> where the outer Trie's keys are firtnames and the inner ones are surnames (or vice versa)?

Hi, thanks for you answer. Using your solution I have to know if the search begin with lastname or firstname, but I have only one textbox that can be filled with a string containing or firstname+surname or surname+firstname.
So do you think that there's no better solution? Thanks very much. I want to solve this problem in the better way. Thanks very very much.

You can also store records simply under the first and surnames (and don't do the two concatenated versions). When you search you do the same with the query string from the textbox. Simply split it by spaces into tokens, use each token to query and insert the results into an auxiliary Set<T>. The Set<T> will be your result set of T's that either matched by firstname or surname or both. Use a TreeSet<T> with a custom Comparator to bring your results into some meaningful order.

I thanks again for you answer. It's a good solution but it has a problem if the firstname contains two name and the same for lastname when I split the string in the textbox I could find results not valid. I don't know if I can explain.

Thanks. Bye

Hi, here is a solution for pseudonym: http://code.google.com/p/autocomplete-server/

My question is this: is it possibile to have a patricia trie like this?
PatriciaTrer<list,List>. Where list of string is a list containing all name in the form of firstname+surname and surname+firstname.

Thanks very much for your attention.