I got a little problem I want to use nltk corpus in hdfs,But failed.For example I want to load nltk.stopwords in my python code.
I use this http://eigenjoy.com/2009/11/18/how-to-use-cascading-with-hadoop-streaming/
我说了这么多,但我不知道如何在我的工作中转化它。我的 nltk 文件名是 nltk-2.0.1.rc1 我的 pyam 文件名是 PyYAML.3.0.1 所以我的命令是:
zip -r nltkandyaml.zip nltk-2.0.1.rc1 PyYAML.3.0.1
然后它说“mv ntlkandyaml.zip /path/to/where/your/mapper/will/be/nltkandyaml.mod”
我的 mapper.py 保存在 /home/mapreduce/mapper.py 所以我的命令是:
mv ntlkandyaml.zip /home/mapreduce/nltkandyaml.mod
那正确吗?
然后我压缩我的语料库停用词:
zip -r /nltk_data/corpora/stopwords-flat.zip *
在我的代码中,我使用:
importer = zipimport.zipimporter('nltkandyaml.mod')
yaml = importer.load_module('PyYAML-3.09')
nltk = importer.load_module('nltk-2.1.0.1rc1')
from nltk.corpus.reader import stopwords
from nltk.corpus.reader import StopWordsCorpusReader
nltk.data.path+=["."]
stopwords = StopWordsCorpusReader(nltk.data.find('lib/stopwords-flat.zip'))
最后我使用命令:
bin/hadoop jar /home/../streaming/hadoop-0.21.0-streaming.jar -input
/user/root/input/voa.txt -output /user/root/output -mapper /home/../mapper.py -reducer
/home/../reducer.py -file /home/../nltkandyaml.mod -file /home/../stopwords-flat.zip
请告诉我哪里错了
谢谢你们