NLTK的安裝教程及安裝錯誤解決方案
成功解決NLTK包的安裝錯誤
- 創(chuàng)建環(huán)境
NLP_Pre_train
l環(huán)境
conda create -n NLP_Pre_train python=3.8
- 激活
conda activate NLP_Pre_train
- 安裝NLTK,套用以下命令
pip install NLTK
- 之后是驗證NLTK是否安裝成功,采用的步驟如下所示:
import nltk nltk.download()
但是不出意外的是,很多人出現(xiàn)的錯誤,如下所示:
為了解決此項問題,我們可以采用離線安裝的方式進行解決。
NLTK的離線安裝
- 首先現(xiàn)在離線安裝包,我們直接去官網(wǎng)進行下載:https://github.com/nltk/nltk_data,安裝的文件,如下所示:
- 我們將下載的文件存放的位置如下所示
- 我們將下載的以下文件文件,放進文件2所展示的位置,這樣便大功告成!
NLTK的驗證
我們可以打印出,NLTK的英文停用詞(STOP word)。
from nltk.corpus import stopwords print(stopwords.words('english'))
打印結(jié)果如下所示:
['i', 'me', 'my', 'myself', 'we', 'our', 'ours', 'ourselves', 'you', "you're",
"you've", "you'll", "you'd", 'your', 'yours', 'yourself', 'yourselves', 'he',
'him', 'his', 'himself', 'she', "she's", 'her', 'hers', 'herself', 'it', "it's",
'its', 'itself', 'they', 'them', 'their', 'theirs', 'themselves', 'what', 'which',
'who', 'whom', 'this', 'that', "that'll", 'these', 'those', 'am', 'is', 'are',
'was', 'were', 'be', 'been', 'being', 'have', 'has', 'had', 'having', 'do',
'does', 'did', 'doing', 'a', 'an', 'the', 'and', 'but', 'if', 'or', 'because',
'as', 'until', 'while', 'of', 'at', 'by', 'for', 'with', 'about', 'against',
'between', 'into', 'through', 'during', 'before', 'after', 'above', 'below',
'to', 'from', 'up', 'down', 'in', 'out', 'on', 'off', 'over', 'under', 'again',
'further', 'then', 'once', 'here', 'there', 'when', 'where', 'why', 'how',
'all', 'any', 'both', 'each', 'few', 'more', 'most', 'other', 'some', 'such', 'no',
'nor', 'not', 'only', 'own', 'same', 'so', 'than', 'too', 'very', 's', 't',
'can', 'will', 'just', 'don', "don't", 'should', "should've", 'now', 'd', 'll',
'm', 'o', 're', 've', 'y', 'ain', 'aren', "aren't", 'couldn', "couldn't",
'didn', "didn't", 'doesn', "doesn't", 'hadn', "hadn't", 'hasn', "hasn't",
'haven', "haven't", 'isn', "isn't", 'ma', 'mightn', "mightn't", 'mustn',
"mustn't", 'needn', "needn't", 'shan', "shan't", 'shouldn', "shouldn't",
'wasn', "wasn't", 'weren', "weren't", 'won', "won't", 'wouldn', "wouldn't"
本文詳細(xì)介紹了NLTK的安裝方法和常見錯誤解決方案,對初學(xué)者很有幫助。另外,本文還對比了NLTK和其他自然語言處理工具的優(yōu)缺點,為讀者提供了選型參考??偟膩碚f,NLTK是一款功能強大、易于使用的自然語言處理工具,值得學(xué)習(xí)和使用。
到此這篇關(guān)于NLTK的安裝教程及安裝錯誤解決方案的文章就介紹到這了,更多相關(guān)NLTK的安裝內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Python實現(xiàn)遠(yuǎn)程調(diào)用MetaSploit的方法
這篇文章主要介紹了Python實現(xiàn)遠(yuǎn)程調(diào)用MetaSploit的方法,是很有借鑒價值的一個技巧,需要的朋友可以參考下2014-08-08詳解Python中open()函數(shù)指定文件打開方式的用法
well,我們這里所指的文件打開方式并不是指調(diào)用什么應(yīng)用程序去打開某個文件,而是只讀只寫或者二進制等的打開方式,這里我們就來詳解Python中open()函數(shù)指定文件打開方式的用法2016-06-06Python基礎(chǔ)之函數(shù)嵌套知識總結(jié)
今天帶大家回顧python基礎(chǔ)知識,文中對Python函數(shù)嵌套作了非常詳細(xì)的知識總結(jié),對正在學(xué)習(xí)python基礎(chǔ)的小伙伴們很有幫助,需要的朋友可以參考下2021-05-05Python+eval函數(shù)實現(xiàn)動態(tài)地計算數(shù)學(xué)表達(dá)式詳解
Python的 eval() 允許從基于字符串或基于編譯代碼的輸入中計算任意Python表達(dá)式。當(dāng)從字符串或編譯后的代碼對象的任何輸入中動態(tài)計算Python表達(dá)式時,此函數(shù)非常方便。本文將利用eval實現(xiàn)動態(tài)地計算數(shù)學(xué)表達(dá)式,需要的可以參考一下2022-09-09