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

相关推荐
Rabbit_QL5 天前
【BPE实战】从零实现 BPE 分词器:训练、编码与解码
python·算法·nlp
这张生成的图像能检测吗5 天前
(论文速读)XLNet:语言理解的广义自回归预训练
人工智能·计算机视觉·nlp·注意力机制
肾透侧视攻城狮5 天前
《NLP核心能力构建:从传统统计到上下文感知的文本表示演进之路》
人工智能·nlp·fasttext·word2vec/glove·elmo/n-gram/词袋·doc2vec/lda·句向量与文档向量
换个名字就很好6 天前
cursor安装和编程
nlp
智海观潮7 天前
Vanna-ai - 让自然语言对话SQL数据库成为可能,支持多种数据库,大模型和向量存储
大数据·nlp·aigc
TvxzFtDBIxok12 天前
基于MATLAB/Simulink的4机10节点系统暂态稳定性仿真
nlp
查无此人byebye15 天前
【超详细解读(GPU)】基于DiT的MNIST扩散模型(DDPM)完整实现
python·深度学习·nlp·transformer·多分类
乌萨奇53715 天前
【2025考研复试】深度学习扩展知识:从ViT到多模态,以及简历项目挖掘策略(第11章复盘)
人工智能·深度学习·考研·计算机视觉·nlp·多模态
查无此人byebye16 天前
基于DiT+DDPM的MNIST数字生成:模型推理实战教程
人工智能·python·深度学习·nlp·transformer
Yaozh、17 天前
【word2vec模型】两种模型结构CBOW和Skip-gram的具体过程
人工智能·深度学习·神经网络·自然语言处理·nlp·word2vec