NLTK的安裝教程及安裝錯(cuò)誤解決方案
成功解決NLTK包的安裝錯(cuò)誤
- 創(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
- 之后是驗(yàn)證NLTK是否安裝成功,采用的步驟如下所示:
import nltk nltk.download()
但是不出意外的是,很多人出現(xiàn)的錯(cuò)誤,如下所示:
為了解決此項(xiàng)問(wèn)題,我們可以采用離線安裝的方式進(jìn)行解決。
NLTK的離線安裝
- 首先現(xiàn)在離線安裝包,我們直接去官網(wǎng)進(jìn)行下載:https://github.com/nltk/nltk_data,安裝的文件,如下所示:
- 我們將下載的文件存放的位置如下所示
- 我們將下載的以下文件文件,放進(jìn)文件2所展示的位置,這樣便大功告成!
NLTK的驗(yàn)證
我們可以打印出,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的安裝方法和常見(jiàn)錯(cuò)誤解決方案,對(duì)初學(xué)者很有幫助。另外,本文還對(duì)比了NLTK和其他自然語(yǔ)言處理工具的優(yōu)缺點(diǎn),為讀者提供了選型參考??偟膩?lái)說(shuō),NLTK是一款功能強(qiáng)大、易于使用的自然語(yǔ)言處理工具,值得學(xué)習(xí)和使用。
到此這篇關(guān)于NLTK的安裝教程及安裝錯(cuò)誤解決方案的文章就介紹到這了,更多相關(guān)NLTK的安裝內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- win10子系統(tǒng)python開(kāi)發(fā)環(huán)境準(zhǔn)備及kenlm和nltk的使用教程
- Windows 64位下python3安裝nltk模塊
- win10 64bit下python NLTK安裝教程
- Windows下Anaconda2安裝NLTK教程
- NLTK 3.2.4 環(huán)境搭建教程
- python2.7和NLTK安裝詳細(xì)教程
- Python自然語(yǔ)言處理 NLTK 庫(kù)用法入門(mén)教程【經(jīng)典】
- Python編程使用NLTK進(jìn)行自然語(yǔ)言處理詳解
- 在Python中使用NLTK庫(kù)實(shí)現(xiàn)對(duì)詞干的提取的教程
相關(guān)文章
Python實(shí)現(xiàn)遠(yuǎn)程調(diào)用MetaSploit的方法
這篇文章主要介紹了Python實(shí)現(xiàn)遠(yuǎn)程調(diào)用MetaSploit的方法,是很有借鑒價(jià)值的一個(gè)技巧,需要的朋友可以參考下2014-08-08詳解Python中open()函數(shù)指定文件打開(kāi)方式的用法
well,我們這里所指的文件打開(kāi)方式并不是指調(diào)用什么應(yīng)用程序去打開(kāi)某個(gè)文件,而是只讀只寫(xiě)或者二進(jìn)制等的打開(kāi)方式,這里我們就來(lái)詳解Python中open()函數(shù)指定文件打開(kāi)方式的用法2016-06-06Python基礎(chǔ)之函數(shù)嵌套知識(shí)總結(jié)
今天帶大家回顧python基礎(chǔ)知識(shí),文中對(duì)Python函數(shù)嵌套作了非常詳細(xì)的知識(shí)總結(jié),對(duì)正在學(xué)習(xí)python基礎(chǔ)的小伙伴們很有幫助,需要的朋友可以參考下2021-05-05Python爬蟲(chóng)設(shè)置代理IP(圖文)
在本篇內(nèi)容里小編給大家分享了關(guān)于Python爬蟲(chóng)設(shè)置代理IP的相關(guān)知識(shí)點(diǎn)和步驟,需要的朋友們參考下。2018-12-12Python+eval函數(shù)實(shí)現(xiàn)動(dòng)態(tài)地計(jì)算數(shù)學(xué)表達(dá)式詳解
Python的 eval() 允許從基于字符串或基于編譯代碼的輸入中計(jì)算任意Python表達(dá)式。當(dāng)從字符串或編譯后的代碼對(duì)象的任何輸入中動(dòng)態(tài)計(jì)算Python表達(dá)式時(shí),此函數(shù)非常方便。本文將利用eval實(shí)現(xiàn)動(dòng)態(tài)地計(jì)算數(shù)學(xué)表達(dá)式,需要的可以參考一下2022-09-09Python使用正則實(shí)現(xiàn)計(jì)算字符串算式
這篇文章主要介紹了Python使用正則實(shí)現(xiàn)計(jì)算字符串算式的方法,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-12-12