复制命令 fasttext 查询并保存 FastText 向量
Replicate the command fasttext Query and save FastText vectors
我正在设置 nlp 预处理,使用预训练的 FastText 模型来查询和保存词向量。我 运行 变成 FileNotFoundError: [Errno 2] No such file or directory: 'fasttext': 'fasttext'
并且此时无法解决它。
这是我正在进行的一个 nlp 临床文本相似性项目。我仔细检查以确保目录中存在所有文件和文件夹。我还想指出,我同时使用了 floydhub 和 google colab 以确保这不是环境问题。我经历了两次这个过程并以同样的错误结束。第二组眼睛绝对有帮助。
复制命令 fasttext print-vectors model.bin < words.txt >> vectors.vec 的代码如下:
with open(VOCAB_FILE) as f_vocab:
with open(OUTPUT_FILE, 'a') as f_output:
subprocess.run(
[FASTTEXT_EXECUTABLE, 'print-word-vectors', PRETRAINED_MODEL_FILE],
stdin=f_vocab,
stdout=f_output)
The traceback error I am getting is below:
FileNotFoundError Traceback (most recent call last)
<ipython-input-150-7b469ee34f75> in <module>()
4 [FASTTEXT_EXECUTABLE, 'print-word-vectors', PRETRAINED_MODEL_FILE],
5 stdin=f_vocab,
----> 6 stdout=f_output)
/usr/local/lib/python3.6/subprocess.py in run(input, timeout, check, *popenargs, **kwargs)
401 kwargs['stdin'] = PIPE
402
--> 403 with Popen(*popenargs, **kwargs) as process:
404 try:
405 stdout, stderr = process.communicate(input, timeout=timeout)
/usr/local/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.
/usr/local/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
FileNotFoundError: [Errno 2] No such file or directory: 'fasttext': 'fasttext'
预期的结果是能够查询和保存 fasttext 向量。我们上面的代码片段从 github repo 获取并用于 Kaggles Quora 问题对。
必须安装 Fasttext 才能查询和保存 Fasttext 向量。
我正在设置 nlp 预处理,使用预训练的 FastText 模型来查询和保存词向量。我 运行 变成 FileNotFoundError: [Errno 2] No such file or directory: 'fasttext': 'fasttext'
并且此时无法解决它。
这是我正在进行的一个 nlp 临床文本相似性项目。我仔细检查以确保目录中存在所有文件和文件夹。我还想指出,我同时使用了 floydhub 和 google colab 以确保这不是环境问题。我经历了两次这个过程并以同样的错误结束。第二组眼睛绝对有帮助。
复制命令 fasttext print-vectors model.bin < words.txt >> vectors.vec 的代码如下:
with open(VOCAB_FILE) as f_vocab:
with open(OUTPUT_FILE, 'a') as f_output:
subprocess.run(
[FASTTEXT_EXECUTABLE, 'print-word-vectors', PRETRAINED_MODEL_FILE],
stdin=f_vocab,
stdout=f_output)
The traceback error I am getting is below:
FileNotFoundError Traceback (most recent call last)
<ipython-input-150-7b469ee34f75> in <module>()
4 [FASTTEXT_EXECUTABLE, 'print-word-vectors', PRETRAINED_MODEL_FILE],
5 stdin=f_vocab,
----> 6 stdout=f_output)
/usr/local/lib/python3.6/subprocess.py in run(input, timeout, check, *popenargs, **kwargs)
401 kwargs['stdin'] = PIPE
402
--> 403 with Popen(*popenargs, **kwargs) as process:
404 try:
405 stdout, stderr = process.communicate(input, timeout=timeout)
/usr/local/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.
/usr/local/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
FileNotFoundError: [Errno 2] No such file or directory: 'fasttext': 'fasttext'
预期的结果是能够查询和保存 fasttext 向量。我们上面的代码片段从 github repo 获取并用于 Kaggles Quora 问题对。
必须安装 Fasttext 才能查询和保存 Fasttext 向量。