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

相关推荐
玄同7656 小时前
Python 异常捕获与处理:从基础语法到工程化实践的万字深度指南
开发语言·人工智能·python·自然语言处理·正则表达式·nlp·知识图谱
庚昀◟18 小时前
用AI来“造AI”!Nexent部署本地智能体的沉浸式体验
人工智能·ai·nlp·持续部署
玄同7651 天前
Python 正则表达式:LLM 噪声语料的精准清洗
人工智能·python·自然语言处理·正则表达式·nlp·知识图谱·rag
natide1 天前
表示/嵌入差异-5-皮尔森相关系数(Pearson Correlation Coefficient)
人工智能·深度学习·机器学习·自然语言处理·nlp
云雾J视界3 天前
年终复盘2.0:NLP自动萃取经验教训,构建可执行策略库
人工智能·docker·nlp·复盘·技术架构·工业级设计
weixin_437497774 天前
读书笔记:Context Engineering 2.0 (上)
人工智能·nlp
极客小云4 天前
【生物医学NLP信息抽取:药物识别、基因识别与化学物质实体识别教程与应用】
python·机器学习·nlp
玄同7654 天前
Python 数据类型:LLM 语料与 API 参数的底层处理逻辑
开发语言·人工智能·python·自然语言处理·llm·nlp·知识图谱
玄同7654 天前
Python 真零基础入门:从 “什么是编程” 到 LLM Prompt 模板生成
人工智能·python·语言模型·自然语言处理·llm·nlp·prompt
C嘎嘎嵌入式开发5 天前
语言学:自然语言处理 (NLP) 的底层逻辑
人工智能·python·自然语言处理·nlp