Python 当NLTK";“朋克”;需要
我已经编写了一些需要使用NLTK的punkt的代码。我已将Python 当NLTK";“朋克”;需要,python,continuous-integration,nltk,github-actions,building-github-actions,Python,Continuous Integration,Nltk,Github Actions,Building Github Actions,我已经编写了一些需要使用NLTK的punkt的代码。我已将nltk包含在requirements.txt和setup.py中。但是,当我使用GitHub操作运行项目的构建时,它会失败并出现此错误 E LookupError: E ********************************************************************** E Resource punkt not found. E
nltk
包含在requirements.txt
和setup.py
中。但是,当我使用GitHub操作运行项目的构建时,它会失败并出现此错误
E LookupError:
E **********************************************************************
E Resource punkt not found.
E Please use the NLTK Downloader to obtain the resource:
E
E >>> import nltk
E >>> nltk.download('punkt')
告诉GitHub操作它需要'punkt'
而不需要硬编码nltk的标准方法是什么?下载('punkt')
?
我应该在
ci.yml
文件中添加一行吗?最好的方法是什么?在ci.yml
文件中,在导入requirements.txt
中定义的依赖项后添加nltk.downloader
命令行对我来说很有效
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python -m nltk.downloader punkt stopwords
我找到了一种解决方法,在使用pytest运行测试之前,在
ci.yml
中添加echo-e“import-nltk\nnltk.download('punkt')”| python3
。但是,任何更优雅的解决方案都是非常受欢迎的。尝试创建nltk.txt文件,并包括punkt
?还使用了andrea提出的ci.yml
更改。似乎在工作:D