2015-09-12 31 views
2

試圖在Python中學習NLP和情感分析,並遇到NLTK。有幾個教程,但卡住了標記化函數,因爲它不適用於我(命令行是說我沒有資源)。Python NLTK錯誤:找不到NLTK中的english.pickle資源

我已經嘗試安裝punkt,儘管已下載,在命令行中仍存在相同的錯誤:

Resource u'taggers/maxent_treebank_pos_tagger/english.pickle' 
not found. Please use the NLTK Downloader to obtain the 
resource: >>> nltk.download() 
Searched in: 
    - 'C:\\Users\\JeromePogi/nltk_data' 
    - 'C:\\nltk_data' 
    - 'D:\\nltk_data' 
    - 'E:\\nltk_data' 
    - 'C:\\Python27\\nltk_data' 
    - 'C:\\Python27\\lib\\nltk_data' 
    - 'C:\\Users\\JeromePogi\\AppData\\Roaming\\nltk_data' 
    - u'' 

我從字面上嘗試了一切,包括把nltk_data夾中的每個它有目錄搜索但無濟於事。我能做些什麼來解決這個錯誤?

+1

可能的重複[無法加載與nltk.data.load英文版](http://stackoverflow.com/questions/4867197/failed-loading-english-pickle-with-nltk-data-load) – alvas

+0

'導入nltk; nltk.download('all')' – alvas

+0

不是重複的,它缺少一個不同的資源。 @Alvas,如果你不知道丟失的特定資源,推薦'nltk.download('book')'就足夠了。 (或避免將來出現類似問題。) – alexis

回答

6

嘗試安裝 「maxent_treebank_pos_tagger」 在Python控制檯

+0

嗨。這工作,非常感謝! –

+1

可能的重複(從3-4年前開始)建議'nltk.download('punkt')' - 有什麼區別? –

+1

「punkt」標記模型用於將純文本分解爲句子,並在NLTK讀取純文本語料時使用。對於POS標記,您需要maxent tagger的模型。 – alexis

3

從外殼/終端/ CMD使用nltk.download(),您可以使用:

python -m nltk.downloader maxent_treebank_pos_tagger 

(可能需要在Linux上須藤)

它將安裝maxent_treebank_pos_tagger(即NLTK中的標準樹庫POS標記器)並解決您的問題。