Обертка Gensim fasttext возвращает ошибку разрешения 13 во время обучения модели

Я попытался воспроизвести это руководство на своем локальный компьютер, чтобы привыкнуть к функциям gensim fasttext. Библиотеки Fasttext и gensim установлены правильно. Вызывая метод train оболочки gensim fasttext

model_wrapper = FT_wrapper.train(ft_home, lee_train_file)

Я получаю следующую ошибку:

---------------------------------------------------------------------------
PermissionError                           Traceback (most recent call last)
<ipython-input-19-0815ab031d23> in <module>()
      3 
      4 # train the model
----> 5 model_wrapper = FT_wrapper.train(ft_home, lee_train_file)
      6 
      7 print(model_wrapper)

~/anaconda3/lib/python3.6/site-packages/gensim/models/deprecated/fasttext_wrapper.py in train(cls, ft_path, corpus_file, output_file, model, size, alpha, window, min_count, word_ngrams, loss, sample, negative, iter, min_n, max_n, sorted_vocab, threads)
    240             cmd.append(str(value))
    241 
--> 242         utils.check_output(args=cmd)
    243         model = cls.load_fasttext_format(output_file)
    244         cls.delete_training_files(output_file)

~/anaconda3/lib/python3.6/site-packages/gensim/utils.py in check_output(stdout, *popenargs, **kwargs)
   1795     try:
   1796         logger.debug("COMMAND: %s %s", popenargs, kwargs)
-> 1797         process = subprocess.Popen(stdout=stdout, *popenargs, **kwargs)
   1798         output, unused_err = process.communicate()
   1799         retcode = process.poll()

~/anaconda3/lib/python3.6/subprocess.py in __init__(self, args, bufsize, executable, stdin, stdout, stderr, preexec_fn, close_fds, shell, cwd, env, universal_newlines, startupinfo, creationflags, restore_signals, start_new_session, pass_fds, encoding, errors)
    707                                 c2pread, c2pwrite,
    708                                 errread, errwrite,
--> 709                                 restore_signals, start_new_session)
    710         except:
    711             # Cleanup if the child failed starting.

~/anaconda3/lib/python3.6/subprocess.py in _execute_child(self, args, executable, preexec_fn, close_fds, pass_fds, cwd, env, startupinfo, creationflags, shell, p2cread, p2cwrite, c2pread, c2pwrite, errread, errwrite, restore_signals, start_new_session)
   1342                         if errno_num == errno.ENOENT:
   1343                             err_msg += ': ' + repr(err_filename)
-> 1344                     raise child_exception_type(errno_num, err_msg, err_filename)
   1345                 raise child_exception_type(err_msg)
   1346 

PermissionError: [Errno 13] Permission denied: '/Users/marcomattioli/fastText'

Обратите внимание, что у меня есть права -rwxr-xr-x на исполняемый файл fasttext. Любая помощь оценена, как это исправить.


person Marco    schedule 04.11.2018    source источник


Ответы (1)


Методы устарели.

Используйте следующие коды:

from gensim.models.fasttext import FastText
from gensim.test.utils import datapath
corpus_file = datapath('lee_background.cor')  # absolute path to corpus
model3 = FastText(size=4, window=3, min_count=1)
model3.build_vocab(corpus_file=corpus_file)
total_words = model3.corpus_total_words
model3.train(corpus_file=corpus_file, total_words=total_words, epochs=10)
person Yang Young    schedule 05.11.2019