如何使用 "pip install -r requirements.txt "通过 "requirements.txt "下载NLTK体例?

问题描述 投票:0回答:1

你可以下载NLTK语料库 punktwordnet 通过命令行下载。

python3 -m nltk.downloader punkt wordnet

如何通过命令行下载NLTK语料库?requirements.txt 使用 pip install -r requirements.txt?

例如,你可以下载空间模型 requirements.txt 使用 pip install -r requirements.txt 添加模型的URL (例如) https:/github.comexplosionspacy-modelsreleasesdownloaden_core_web_sm-2.0.0en_core_web_sm-2.0.0.tar.gz#egg=en_core_web_sm==2.0.0。requirements.txt)

python pip nltk corpus requirements.txt
1个回答
3
投票

如何通过命令行下载NLTK体素?requirements.txt

简短的回答:不可能。

spacy模型的URL指向一个 Python包 (setup.py 和所有这些),所以它可以下载和安装由 pip. 不存在这种情况。pip-NLTK数据的可安装包。nltk.downloader 以自己的格式下载数据。


1
投票

实际上没有办法通过一个requirements.txt文件来实现。但是,如果你需要在wordnet和punkt中使用NLTK,你可以有两个文件。然后在其中一个文件中下载nltk数据,并将该文件导入到你的主文件中。例如

nltkmodules.py。

import nltk

nltk.download('wordnet')
nltk.download('punkt')

main.py:

import nltkmodules

# Rest of Code goes here

在你的requirements.txt中,你可以只包含:

nltk==3.5
© www.soinside.com 2019 - 2024. All rights reserved.