NLTK下载punkt

python 复制代码
from nltk import word_tokenize


sents = [sent1, sent2]
print(word_tokenize(sent1))

报错:

python 复制代码
D:\Anaconda3\python.exe "D:/002 知识总结/007 NLP/NLP入门文章/词袋模型与句子相似度.py"
[nltk_data] Error loading punkt: <urlopen error [SSL:
[nltk_data]     CERTIFICATE_VERIFY_FAILED] certificate verify failed:
[nltk_data]     unable to get local issuer certificate (_ssl.c:1123)>
Traceback (most recent call last):
  File "D:/002 知识总结/007 NLP/NLP入门文章/词袋模型与句子相似度.py", line 11, in <module>
    print(word_tokenize(sent1))
  File "D:\Anaconda3\lib\site-packages\nltk\tokenize\__init__.py", line 129, in word_tokenize
    sentences = [text] if preserve_line else sent_tokenize(text, language)
  File "D:\Anaconda3\lib\site-packages\nltk\tokenize\__init__.py", line 106, in sent_tokenize
    tokenizer = load("tokenizers/punkt/{0}.pickle".format(language))
  File "D:\Anaconda3\lib\site-packages\nltk\data.py", line 752, in load
    opened_resource = _open(resource_url)
  File "D:\Anaconda3\lib\site-packages\nltk\data.py", line 877, in _open
    return find(path_, path + [""]).open()
  File "D:\Anaconda3\lib\site-packages\nltk\data.py", line 585, in find
    raise LookupError(resource_not_found)
LookupError: 
**********************************************************************
  Resource punkt not found.
  Please use the NLTK Downloader to obtain the resource:

  >>> import nltk
  >>> nltk.download('punkt')
  
  For more information see: https://www.nltk.org/data.html

  Attempted to load tokenizers/punkt/english.pickle

  Searched in:
    - 'C:\\Users\\29617/nltk_data'
    - 'D:\\Anaconda3\\nltk_data'
    - 'D:\\Anaconda3\\share\\nltk_data'
    - 'D:\\Anaconda3\\lib\\nltk_data'
    - 'C:\\Users\\29617\\AppData\\Roaming\\nltk_data'
    - 'C:\\nltk_data'
    - 'D:\\nltk_data'
    - 'E:\\nltk_data'
    - ''
**********************************************************************


进程已结束,退出代码为 1

解决方法:

【Python】nltk库使用报错之punkt安装:https://blog.csdn.net/weixin_43896318/article/details/106191856

相关推荐
阿图灵1 天前
基于 GRU 的 Seq2Seq 中英机器翻译:从 Tatoeba 语料到 BLEU 0.195
深度学习·gru·nlp·机器翻译·seq2seq
网络工程小王2 天前
【HCIE-AI】4.NLP 核心任务与技术演进学习笔记
人工智能·深度学习·自然语言处理·nlp·transformer
Lee_jerome2 天前
python神经网络编程入门(三十五)——Transformer 整体架构——一张图看懂全貌
nlp·transformer·encoder·注意力机制·decoder·交叉注意力·self-attention
Lee_jerome3 天前
python神经网络编程入门(三十三)——多头注意力(Multi-Head Attention)
深度学习·nlp·transformer·注意力机制·多头注意力·self-attention
Lee_jerome5 天前
python神经网络编程入门(三十)——Transformer 从 RNN 到注意力:模型为什么需要“瞄一眼“
rnn·深度学习·nlp·transformer·attention·注意力机制·序列建模
阿图灵6 天前
基于 LSTM 的中文电商评论情感分类:从数据处理到 91% 准确率实战
人工智能·深度学习·分类·nlp·lstm·情感分类
方品8 天前
【无标题】
服务器·人工智能·深度学习·nlp
今日无bug9 天前
用 Prompt 做 NLP 任务开发:几分钟构建一个推理系统
llm·nlp
uncle_ll11 天前
GPT 中文文本生成指南:从开箱调用到定制化微调,吃透 Transformer 解码器核心 logic
gpt·深度学习·llm·nlp·transformer
uncle_ll12 天前
服务器选型、微调范式、训练优化与环境搭建
服务器·python·gpt·llm·nlp