離線安裝 nltk_data


自然語言處理練習時,經常使用nltk模塊,需要使用nltk_data的數據,nltk_data可以直接使用
nltk.download()直接下載安裝。然而,nltk_data體積比較大,很難下載,離線安裝時一個比較好的選擇。
1、首先python安裝nltk模塊。
2、下載nltk_data離線文件,網上有資源,百度下載即可,nltk_data.tar.gz。
3、查詢nltk搜索的目錄

import nltk
nltk.data.find(".")

4、nltk_data文件放到第3步搜索的目錄下
解壓nltk_data.tar.gz文件,得到文件夾nltk_data,並將nltk_data移動到第3步搜索的目錄下
5、測試

from nltk.book import *

看到已下結果即安裝成功

*** Introductory Examples for the NLTK Book ***
Loading text1, ..., text9 and sent1, ..., sent9
Type the name of the text or sentence to view it.
Type: 'texts()' or 'sents()' to list the materials.
text1: Moby Dick by Herman Melville 1851
text2: Sense and Sensibility by Jane Austen 1811
text3: The Book of Genesis
text4: Inaugural Address Corpus
text5: Chat Corpus
text6: Monty Python and the Holy Grail
text7: Wall Street Journal
text8: Personals Corpus
text9: The Man Who Was Thursday by G . K . Chesterton 1908

參考
https://blog.csdn.net/zhangcucmb/article/details/80824231


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM