解决nltk的问题

解决nltk的问题

Traceback (most recent call last):
  File "D:/pywork/transformer/transformer1.py", line 109, in <module>
    train_inputs, train_outputs = segmentation(Path_train_en, Path_train_cn, mode='train')
  File "D:/pywork/transformer/transformer1.py", line 101, in segmentation
    inputs = get_inputs_nltk(data_en[:train_len])      
  File "D:/pywork/transformer/transformer1.py", line 80, in get_inputs_nltk
    line = word_tokenize(line)
  File "D:\F\Anaconda3\envs\pytorch\lib\site-packages\nltk\tokenize\__init__.py", line 129, in word_tokenize
    sentences = [text] if preserve_line else sent_tokenize(text, language)
  File "D:\F\Anaconda3\envs\pytorch\lib\site-packages\nltk\tokenize\__init__.py", line 106, in sent_tokenize
    tokenizer = load("tokenizers/punkt/{0}.pickle".format(language))
  File "D:\F\Anaconda3\envs\pytorch\lib\site-packages\nltk\data.py", line 752, in load
    opened_resource = _open(resource_url)
  File "D:\F\Anaconda3\envs\pytorch\lib\site-packages\nltk\data.py", line 877, in _open
    return find(path_, path + [""]).open()
  File "D:\F\Anaconda3\envs\pytorch\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\\49135/nltk_data'
    - 'D:\\F\\Anaconda3\\envs\\pytorch\\nltk_data'
    - 'D:\\F\\Anaconda3\\envs\\pytorch\\share\\nltk_data'
    - 'D:\\F\\Anaconda3\\envs\\pytorch\\lib\\nltk_data'
    - 'C:\\Users\\49135\\AppData\\Roaming\\nltk_data'
    - 'C:\\nltk_data'
    - 'D:\\nltk_data'
    - 'E:\\nltk_data'
    - ''
**********************************************************************

解决方法:
下载好nltk之后,解压,放在D:\F\Anaconda3\envs\pytorch\nltk_data目录下,新建一个文件夹tokenizers,然后将解压好的nltk文件夹粘贴过来。
服务器上和本地都可以这样操作。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值