2017-01-13 8 views
4

저는 word2vec와 GloVe 모델에 대해 파이썬으로 배우므로 여기를 통해 here을 사용할 것입니다.gensim 시작하기 오류 : 해당 파일이나 디렉토리가 없습니다. 'text8'

내가 Idle3 단계로이 코드 단계 컴파일 후 :

>>>from gensim.models import word2vec 
>>>import logging 
>>>logging.basicConfig(format='%(asctime)s : %(levelname)s : %(message)s', level=logging.INFO) 
>>>sentences = word2vec.Text8Corpus('text8') 
>>>model = word2vec.Word2Vec(sentences, size=200) 

나는이 오류가 무엇입니까 : 어떻게이 문제를 해결할 않는

2017-01-13 11:15:41,471 : INFO : collecting all words and their counts 
Traceback (most recent call last): 
    File "<pyshell#4>", line 1, in <module> 
    model = word2vec.Word2Vec(sentences, size=200) 
    File "/usr/local/lib/python3.5/dist-packages/gensim/models/word2vec.py", line 469, in __init__ 
    self.build_vocab(sentences, trim_rule=trim_rule) 
    File "/usr/local/lib/python3.5/dist-packages/gensim/models/word2vec.py", line 533, in build_vocab 
    self.scan_vocab(sentences, progress_per=progress_per, trim_rule=trim_rule) # initial survey 
    File "/usr/local/lib/python3.5/dist-packages/gensim/models/word2vec.py", line 545, in scan_vocab 
    for sentence_no, sentence in enumerate(sentences): 
    File "/usr/local/lib/python3.5/dist-packages/gensim/models/word2vec.py", line 1536, in __iter__ 
    with utils.smart_open(self.fname) as fin: 
    File "/usr/local/lib/python3.5/dist-packages/smart_open-1.3.5-py3.5.egg/smart_open/smart_open_lib.py", line 127, in smart_open 
    return file_smart_open(parsed_uri.uri_path, mode) 
    File "/usr/local/lib/python3.5/dist-packages/smart_open-1.3.5-py3.5.egg/smart_open/smart_open_lib.py", line 558, in file_smart_open 
    return open(fname, mode) 
FileNotFoundError: [Errno 2] No such file or directory: 'text8' 

를? 미리 도움을 주셔서 감사합니다.

답변

4

여기에 사용 된 파일이 누락 된 것 같습니다. 특히 text8을 열려고하는데 찾을 수 없습니다 (따라서 FileNotFoundError).

Docstring:  
Iterate over sentences from the "text8" corpus, unzipped from http://mattmahoney.net/dc/text8.zip . 

를하고 사용 가능하게 :

당신은 in the documentation for Text8Corpus을 언급 한대로 here에서 파일 자체를 다운로드 할 수 있습니다. 그것을을 추출하고 Text8Corpus에 인수로 제공 :

sentences = word2vec.Text8Corpus('/path/to/text8') 
+0

내가 얻을 http://word2vec.googlecode.com/svn/trunk/ 내가 SVN 체크 아웃을 사용 한 후이 ... SVN : E170013 : 없음 'http://word2vec.googlecode.com/svn/trunk'URL의 저장소에 연결하는 중 .... svn : E160013 : '/ svn/trunk'경로를 찾을 수 없습니다 ... 터미널에 입력했습니다. –

+1

@Clueless_programmer는 압축을 풀어서'Text8Corpus'에 대한 경로로 제공합니다. 내 답변을 변경했습니다. –

+0

도움 주셔서 감사합니다. 완료되었습니다. –