(Gensim)Python:FileNotFoundError:[Errno 2]没有这样的文件或目录:'霉菌.txt'

2024-06-14 15:26:04 发布

您现在位置:Python中文网/ 问答频道 /正文

我目前正在学习Gensim关于语料库和向量空间的教程,我现在正试图理解Corpus Streaming – One Document at a Time。在

在我编译了这些代码行之后,在python3中引用了上面的链接:

class MyCorpus(object):
    def __iter__(self):
        for line in open('mycorpus.txt'):
            # assume there's one document per line, tokens separated by whitespace
            yield dictionary.doc2bow(line.lower().split())

corpus_memory_friendly = MyCorpus()  # doesn't load the corpus into memory!

print(corpus_memory_friendly)

for vector in corpus_memory_friendly:  # load one vector into memory at a time
    print(vector)

我得到了这个错误:

^{pr2}$

我已经下载了霉菌.txt我仍然得到这个错误。我应该在哪里存放霉菌.txt文件。在

谢谢你的帮助。在


Tags: intxtfor错误lineloadcorpusone