如何在NLTK中保存自定义分类语料库 [英] How to save a custom categorized corpus in NLTK
问题描述
如何将新语料库保存"到NLTK语料库数据?
How can one 'save' a new corpus to NLTK corpora data?
就我而言,就像我在此页面中所说的那样,在NLTK中创建了新的自定义分类语料库后,
In my case, after I created a new custom categorized corpus in NLTK just like in this page said: Creating a custom categorized corpus in NLTK and Python
我想像在NLTK中已安装的语料库一样使用它(例如movie_reviews).我怎样才能做到这一点?换句话说,如何读取我已经阅读过的新语料库(例如movie_reviews_0):
I want to use it just like an already-installed corpora in NLTK (say movie_reviews). How can I do this? In other words, how can the new corpus I have read (say movie_reviews_0) can be called like this:
>>> import nltk
>>> from nltk.corpus import movie_reviews_0
推荐答案
您可以将其添加到您自己的nltk_data/corpora
文件夹中,该文件夹应位于主目录中.例如,如果您使用的是Mac,它将位于~/nltk_data/corpora
中.而且看来您还必须将新语料库附加到.../site-packages/nltk/corpus/
中的__init__.py
.
You can add it to your own nltk_data/corpora
folder which should be somewhere in your home directory. If you are on a Mac it would be in ~/nltk_data/corpora
, for instance. And it looks like you also have to append your new corpus to the __init__.py
within .../site-packages/nltk/corpus/
.
这篇关于如何在NLTK中保存自定义分类语料库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!