Where can I find a text list or library that contains a list of common foods? [closed]
Asked Answered
M

3

10

I'm writing a Python script that parses emails which involves searching the text of the email for any words that are common food items. I need some way to determine whether words are indeed food items.

I've looked at several natural language processing APIs (such as AlchemyAPI and NLTK 2.0) and they appear to have Named Entity Extraction (which is what I want), but I can't find an entity type for food in particular.

It's quite possible that natural language processing is overkill for what I need-- I just want a list of foods that I can match to. Where can I find such a word list? Do I need to write my own scraper to parse it off some online source, or is there an easier way?

Matisse answered 28/10, 2013 at 3:24 Comment(4)
How about the FDA SR26 database?Sisterhood
ndb.nal.usda.gov/ndb/search/listApplique
check out Michael Wiegand's work: lsv.uni-saarland.de/personalPages/michael/relFood.htmlKa
I had exactly the same problem! I wanted to identify food items in text, I tried AlchemyAPI (didn't work well for food), and now I think I need to roll my own 'find food in text' code.Chromium
K
9

It would be really nice to have all the food items into one single list but sadly that's the ideal case.

You can try accessing the food synset in WordNet. If you are using NLTK, try:

>>> from nltk.corpus import wordnet as wn
>>> food = wn.synset('food.n.02')
>>> list(set([w for s in food.closure(lambda s:s.hyponyms()) for w in s.lemma_names()]))
Ka answered 30/12, 2013 at 15:57 Comment(0)
H
1

AFAIK, there is no entity of common foods for NLTK or similar. It's quite likely you have to construct a list for yourself.

But, thankfully, the internet is your friend, here are a few good sources to start with that cover a lot of common vegetables and fruits in the English-speaking world:

Good luck!

Hluchy answered 28/10, 2013 at 3:39 Comment(0)
H
1

Since named entities are proper nouns (i.e. people, places, companies, locations, etc.), it's unlikely that NLP entity extraction will work for finding common food names. The NLP function that might work is keyword extraction. I ran a few recipes through AlchemyAPI's demo and the ingredients are identified as keywords. So that gets you part of the way there, but you'll still need to compare the keywords to a list of common food items, like jrd1 mentioned.

Helotry answered 29/10, 2013 at 15:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.