在哪里可以找到包含普通食品列表的文本列表或图书馆? [英] Where can I find a text list or library that contains a list of common foods?

查看:74
本文介绍了在哪里可以找到包含普通食品列表的文本列表或图书馆?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个用于解析电子邮件的Python脚本,该脚本涉及在电子邮件的文本中搜索常见食品中的任何单词.我需要某种方法来确定单词是否确实是食物.

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.

我研究了几种自然语言处理API(例如AlchemyAPI和NLTK 2.0),它们似乎具有命名实体提取(这正是我想要的),但是我找不到特定的食物实体类型

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?

推荐答案

把所有食物都放在一个列表中真的很不错,但可悲的是,这是理想的情况.

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

您可以尝试在WordNet中访问food同义词集.如果您使用的是NLTK,请尝试:

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()]))

这篇关于在哪里可以找到包含普通食品列表的文本列表或图书馆?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆