簡體   English   中英

如何使用 `pip install -r requirements.txt` 通過 `requirements.txt` 下載 NLTK 語料庫?

[英]How can I download NLTK corpora via `requirements.txt` using `pip install -r requirements.txt`?

可以通過命令行下載 NLTK 語料庫punktwordnet

python3 -m nltk.downloader punkt wordnet

如何使用pip install -r requirements.txt通過requirements.txt下載 NLTK 語料庫?

For example one can download spacy models requirements.txt using pip install -r requirements.txt by adding the URL of the model (eg https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-2.0.0 /en_core_web_sm-2.0.0.tar.gz#egg=en_core_web_sm==2.0.0 in requirements.txt )

如何通過requirements.txt下載 NLTK 語料庫

簡短的回答:不可能。

The URL for spacy models points to a Python package ( setup.py and all that) so it can be downloaded and installed by pip . 沒有這樣的pip安裝包用於 NLTK 數據。 nltk.downloader以自己的格式下載數據。

無法通過 requirements.txt 文件實際執行此操作。 但是,如果您有必要將 NLTK 用於 wordnet 和 punkt,您可以做的是擁有 2 個文件。 並下載 nltk 數據並將該文件導入您的主文件。 例如,

nltkmodules.py:

import nltk

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

主要.py:

import nltkmodules

# Rest of Code goes here

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

nltk==3.5

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM