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

相关推荐
lin_dec+12 小时前
KV Cache:大模型推理加速的关键技术
nlp·transformer·vllm·大模型推理·kv cache
Learn Beyond Limits14 小时前
多层循环神经网络|Multi-layer RNNs
人工智能·rnn·深度学习·神经网络·机器学习·自然语言处理·nlp
羊小猪~~2 天前
LLM--BERT架构解析
人工智能·深度学习·大模型·llm·nlp·bert·ai算法
带娃的IT创业者2 天前
期中总结:从神经元到 GPT——AI 架构全景回顾(Version B)
人工智能·gpt·深度学习·神经网络·架构·nlp·transformer
Learn Beyond Limits3 天前
长短期记忆网络|LSTM(Long Short-Term Memory)
人工智能·rnn·深度学习·神经网络·自然语言处理·nlp·lstm
Learn Beyond Limits3 天前
双向循环神经网络|Bi-RNN(Bidirectional Recurrent Neural Networks)
人工智能·rnn·深度学习·神经网络·语言模型·自然语言处理·nlp
请数据别和我作队4 天前
基于 DeepSeek API 的 ASR 文本纠错脚本实战:Python 多线程批量处理 JSONL 语音转写数据
开发语言·经验分享·python·自然语言处理·nlp
0 14 天前
260401日志
人工智能·深度学习·nlp
Flying pigs~~7 天前
基于Bert的模型迁移文本分类项目
人工智能·深度学习·算法·大模型·nlp·bert
Flying pigs~~7 天前
基于TF_IDF和Bagging的文本分类全过程
算法·随机森林·机器学习·nlp·文本分类
热门推荐