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

相关推荐
user_admin_god3 天前
Opencode常见问题与优化排查
java·人工智能·自然语言处理·nlp·idea
深圳市快瞳科技有限公司4 天前
医保OCR与医保审核系统融合:智能校验规则设计与实现
nlp·ocr
王_teacher6 天前
RNN 循环神经网络 计算过程(通俗+公式版+运行实例)
人工智能·rnn·nlp
Luca_kill8 天前
实战指南:用 Python + NLP 搭建一套轻量级 AI 舆情监控系统
人工智能·python·机器学习·nlp·舆情监控
墨心@9 天前
Byte-Pair Encoding (BPE) Tokenizer
人工智能·自然语言处理·nlp·datawhale·cs336·组队学习
Shen Planck10 天前
BAAI/bge-m3部署磁盘不足?模型缓存清理操作指南
nlp·大语言模型·baai·语义相似度
xcLeigh11 天前
AI标书底层技术全解析:NLP+大模型落地,喜鹊标书AI如何重构投标效率
人工智能·ai·自然语言处理·重构·大模型·nlp·标书
华农DrLai13 天前
怎么用大模型生成推荐的训练数据?Data Augmentation怎么做?
数据库·人工智能·大模型·nlp·prompt
极光代码工作室16 天前
基于BERT的新闻文本分类系统
深度学习·nlp·bert·文本分类
Learn Beyond Limits17 天前
神经机器翻译|Neural Machine Translation(NMT)
人工智能·神经网络·机器学习·ai·自然语言处理·nlp·机器翻译