gpt4 book ai didi

python - Gensim : IO Error 中的 BleiCorpus 和美联社数据集

转载 作者:太空宇宙 更新时间:2023-11-04 08:09:08 25 4
gpt4 key购买 nike

我正在尝试遵循“使用 Python 构建机器学习系统”一书中关于主题建模/潜在狄利克雷分配 (LDA) 的教程。

我在这本书中没有走得太远,主题建模的第一部分为我返回了错误:

from gensim import corpora, models, similarities
corpus = corpora.BleiCorpus('./data/ap/ap.dat', './data/ap/vocab.txt')

错误:

     63 
64 self.fname = fname
---> 65 with utils.smart_open(fname_vocab) as fin:
66 words = [utils.to_unicode(word).rstrip() for word in fin]
67 self.id2word = dict(enumerate(words))

/Users/user/Library/Enthought/Canopy_64bit/User/lib/python2.7/site-packages/gensim/utils.pyc in smart_open(fname, mode)
659 from gzip import GzipFile
660 return make_closing(GzipFile)(fname, mode)
--> 661 return open(fname, mode)
662
663

IOError: [Errno 2] No such file or directory: './data/ap/vocab.txt'

vocab.txt文件不存在,但是切换到它应该在的目录,我发现如下:

$ ls download_ap.sh download_wp.sh preprocess-wikidata.sh

看来ap的数据需要单独下载(书上没有提到),所以这样做:

sh download_ap.sh

我明白了:

download_ap.sh: line 2: wget: command not found
tar: Error opening archive: Failed to open 'ap.tgz'

有人知道如何解决这个问题吗?

谢谢

最佳答案

您的计算机上没有安装 wget,您使用的是带有 Cygwin 的 Windows 吗?从 http://www.cs.princeton.edu/~blei/lda-c/ap.tgz 下载文件, 解压缩并将其放在正确的文件夹中。

关于python - Gensim : IO Error 中的 BleiCorpus 和美联社数据集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26145937/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com