Page 1 of 1
String correlation
Posted: Fri Aug 14, 2009 10:58 am
by zenon
Hello.
When a user writes a string, for example "spagetti" or "spag" or "spaget" or something like that, i want to recognize the string and put on its place other string, like "pasta" and use the latest string in a query in a database.
I hope i didn't confuse you.
Thank you!
Re: String correlation
Posted: Fri Aug 14, 2009 11:10 am
by jackpf
I may be mistaken, but I don't believe that's possible...
You'd have to make a table or something of correlation. Say, have a field for word match, and then for match value.
Then you can use LIKE with wild cards in the query, to select words that have a correlation, and use that word in the new query instead.
For example:
the table:
Code: Select all
| Word Match| Word Value |
| | |
| spaghetti | pasta |
Say the word is "spag", do:
Code: Select all
SELECT `Word Value` FROM TABLE WHERE `Word Match` LIKE '%spag%'
Then `Word Value` should contain "pasta". If you were to get a bit more advanced, I guess you could have a ranking system, so that if multiple matches are found, you can decide which one is most like what the user meant in context.
Re: String correlation
Posted: Fri Aug 14, 2009 11:17 am
by zenon
Thank you very much jackpf for your helpful advice!
Re: String correlation
Posted: Fri Aug 14, 2009 11:18 am
by jackpf
Sorry, I edited my post to give an example. I wasn't sure if you saw it...I just thought I'd let you know.
Anyway, yeah, no problem. Good luck!
Re: String correlation
Posted: Fri Aug 14, 2009 11:21 am
by zenon
jackpf wrote:Sorry, I edited my post to give an example. I wasn't sure if you saw it...I just thought I'd let you know.
Anyway, yeah, no problem. Good luck!
Yes, i saw it
Thank very much once again! I appreciate it!