0

I know there is a similar thread but it has no useful answer.

I am using SQLITE (can not change language) and when a user fills out a form one of the fields is Category.

I want them to enter a category for example, they can enter: gardening.

But if that category already exists 'Gardening' or they mispell it, it will add an entry and cause issues when I am searching.

I want to know if it's possible to use SOUNDEX on the entry to match it against the database, and if an entry exists which is say 80% similar or something it will give a message:

Did you mean (category)?

Which will be a link that when clicked will change the field entry.

Quite alot I am looking for, so thanks in advance for any help.

UPDATE: My Database has the values which will be similar to. So:

CATEGORY:

GARDENING COOKING DIY

JEV
  • 2,494
  • 4
  • 33
  • 47

1 Answers1

2

Yes, but you'll need to add the soundex values to the database so you can do a search on them. Otherwise you'll need to pull out every record in the table to parse it through soundex to do the match. Pre-baking is the way to go.

Protip: if you want to be a bit fuzzy, loop through the check cutting off segments of the soundex from the entered value. You'll get back a list of first perfect matches, then near ones, then farther still.

DampeS8N
  • 3,621
  • 17
  • 20
  • I can't add them to the database, it's against the spec. – JEV Apr 18 '12 at 20:20
  • @Mombassa who wrote the spec? You need to alert them to the mistake if this functionality needs to exist. Unless you mean the SQLite spec, in which case soundex outputs a string, strings are fine. – DampeS8N Apr 18 '12 at 20:22
  • I understand, it's a job, not their choice; Perhaps if I used similar text and compared percentages, if the percentage was over say 80, I could display it? – JEV Apr 18 '12 at 20:25
  • @Mombassa Actually no, because once again you'll need to check against every category in the system. You might as well use soundex if you are going to be doing that. – DampeS8N Apr 18 '12 at 20:33