Jump to content

Comparing text against a database


kpedini

Recommended Posts

I'm building a website that compiles user submitted recipes and was wondering if anyone had a technique to extract a list of ingredients in a text area and then categorize those ingredients. For example, the user would enter the following:

 

1/2 cup of flour

 

2 cups of butter

 

I would then be able to extract "flour" and "butter" and compare those strings so I can categorize those ingredients as "baking supplies" and "dairy" in the database. The desired result is to be able to compile the various ingredients provided and generate a shopping list.

 

My thought is to explode the text into an array of values and then do a compare on each word against an array of predefined ingredients to find the appropriate category. This approach seems like it could be rather processor intensive, however. I was wondering if anyone had a different approach that would make more sense.

 

Any help is greatly appreciated.

 

Thanks.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.