File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes search algorithm help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "search algorithm help" Watch "search algorithm help" New topic
Author

search algorithm help

Frank king
Greenhorn

Joined: Oct 10, 2004
Posts: 10
I have a database includes list of book names and price.

when key in a book name, system will return its selling price.

however, if user keyed in name wrongly, for exmaple. "risl management" instead of real name "risk management", my system won't know how to handle this type of problem.

another problem is : if user doesn't key in the full name of the book, how the system could know which book the user is looking fot?

any search algorithm can solve this kinds of problems??

thanks, waiting for your help asap.
Arnaud Burlet
Ranch Hand

Joined: Oct 08, 2004
Posts: 31
Hi !

Well, about spelling mistakes correction, that's not an easy thing to do, you may be interrested by a course I followed 2 years ago :
spell checking You'll find an easy algorithm in there...

and about the 2nd point, that's not too hard, create a list of all the words contained in book titles, and associate them full book names containing the word in question. This is certainly not the best idea, but just a starting point...

Arnaud
Ben Wood
Ranch Hand

Joined: Aug 14, 2001
Posts: 342
Frank,

What do you mean by database? For example, if you are talking about connecting to relational database using JDBC you can experiment with LIKE in your SQL queries. If the system doesn't find an exact match you can do some other queries after splitting the query up...

e.g. "Risl Management", also search on "Risl" and "Management"

Query on whole string returns no results, so split it up into individual words (using StringTokenizer maybe ?) and try each one, then output something like "sorry, the title you searched for was not found...here are some possible matches"

again, not perfect, but quite easy to implement


SCJP 1.4, www.gsi3d.org.uk
Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
Here's an alternative approach using an in-memory index instead of database queries: Ternary Search Tree. The demo applet matches a list of words as you type leading characters, so as you type "RIS" you see "RISK" fairly near the top.


A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: search algorithm help
 
Similar Threads
Searching an XML document
need MYSQL searching help
XSLT merging help
==> need search algorithm help
Storing a password to encrypt/decrypt sensitive data.