错误代码:

nlp = English()
nlp.add_pipe(nlp.create_pipe('sentencizer'))

def normalize(text):
    text = text.lower().strip()
    doc = nlp(text)
    filtered_sentences = []
    for sentence in tqdm(doc.sents):#错误在这

错误:

ValueError: [E030] Sentence boundaries unset. You can add the 'sentencizer' component to the pipeline with: nlp.add_pipe(nlp.create_pipe('sentencizer')) Alternatively, add the dependency parser, or set sentence boundaries by setting doc[i].is_sent_start.

原因:

This is currently a limitation of the sentencizer, because the is_sentenced property is based on whether the Token.is_sent_start properties were changed. However, for the first token in a sentence, this will always default to True. So if the sentence only contains one token, there's no way for spaCy to tell whether the sentence boundaries have been set or not.

As a workaround, you could trick spaCy into ignoring this by setting doc.is_parsed = True, i.e. by making it believe that the dependency parse was assigned and sentence boundaries were applied this way.

这当前是sentencizer的限制,因为is_sentenced属性基于Token.is_sent_start属性是否已更改。 但是,对于句子中的第一个标记,它将始终默认为True。 因此,如果句子只包含一个标记,则spaCy无法判断是否已设置句子边界。

作为一种解决方法,你可以通过设置doc.is_parsed = True来欺骗spaCy忽略它,即通过让它相信分配了依赖关系解析并以这种方式应用了句子边界。

解决办法:spacy版本问题,2.1.3换成2.1.0

pip uninstall spacy

pip install spacy==2.1.0

艹怼死我了 这个问题

ValueError: [E030] Sentence boundaries unset. You can add the 'sentencizer' component to the pipelin相关推荐

  1. 机器学习管道模型_使用连续机器学习来运行您的ml管道

    机器学习管道模型 Vaithy NarayananVaithy Narayanan Follow跟随 Jul 15 7月15 使用连续机器学习来运行ML管道 (Using Continuous Mac ...

  2. Tokenisation word segmentation sentence segmentation

    David D. Palmer Chapter 2: Tokenisation and SentenceSegmentation.2000 https://scholar.google.com/cit ...

  3. vue indev.html,webpack - Can't add script tag to Vue component files ( *.vue ) - Stack Overflow

    I'm new to vue.js. I'm trying to render vue component file but when I add to vue component, for exam ...

  4. 谷歌BERT预训练源码解析(一):训练数据生成

    目录 预训练源码结构简介 输入输出 源码解析 参数 主函数 创建训练实例 下一句预测&实例生成 随机遮蔽 输出 结果一览 预训练源码结构简介 关于BERT,简单来说,它是一个基于Transfo ...

  5. react 错误边界_React with GraphQL和错误边界中的自定义错误页面

    react 错误边界 by Abi Noda 通过Abi Noda React with GraphQL和错误边界中的自定义错误页面 (Custom error pages in React with ...

  6. ai css 线条粗细_如何训练AI将您的设计模型转换为HTML和CSS

    ai css 线条粗细 by Emil Wallner 埃米尔·沃尔纳(Emil Wallner) 如何训练AI将您的设计模型转换为HTML和CSS (How you can train an AI ...

  7. 前端要完!人工智能已经能实现自动编写 HTML 和 CSS

    本文转载自:CSDN 资讯 [编者按]一个月前,我们曾发表过一篇标题为<三年后,人工智能将彻底改变前端开发?>的文章,其中介绍了一个彼时名列 GitHub 排行榜 TOP 1 的项目 -- ...

  8. 基于词典的正向最大匹配中文分词算法,能实现中英文数字混合分词

    基于词典的正向最大匹配中文分词算法,能实现中英文数字混合分词.比如能分出这样的词:bb霜.3室.乐phone.touch4.mp3.T恤 第一次写中文分词程序,欢迎拍砖. publicclass MM ...

  9. 基于词典的逆向最大匹配中文分词算法,更好实现中英文数字混合分词

    基于词典的逆向最大匹配中文分词算法,能实现中英文数字混合分词.比如能分出这样的词:bb霜.3室.乐phone.touch4.mp3.T恤.实际分词效果比正向分词效果好 publicclass RMM ...

最新文章

  1. 以太坊源码分析-交易
  2. 类模板 重载运算符 易错
  3. Android之JNI DETECTED ERROR IN APPLICATION: illegal class name ‘XXX‘的错误解决方法
  4. Python笔记-uiautomator2截图点击,OpenCV找图
  5. 低延时互动直播双十一优惠活动
  6. 工业机器人技术试题_《工业机器人技术基础》课程试卷A卷
  7. onSubmit的使用
  8. Pytorch实现FGSM(Fast Gradient Sign Attack)
  9. iOS UI 自动化测试原理以及在 Trip.com 的应用实践
  10. Centos7下内网YUM源搭建
  11. Python多线程操作
  12. 补偿丰厚员工抢着被裁员?滴滴:不予回应
  13. 【Python爬虫实战】查找企业股东有哪些关联公司
  14. 2022.5.25 FreeSurfer入门练习:Recon-all
  15. 下载源码报错Cannot connect to the Maven process. Try again later. If the problem persists, check the Maven
  16. Elasticsearch 7.3.0 翻译 - 《Aggregations》 度量聚合 百分位数聚合
  17. 心灵的呼唤 - Cuchulainn
  18. Python traceback模块:获取异常信息
  19. 聊一聊回收科技那些事儿
  20. android无线充电器推荐,和安卓通用的无线充电器门派推荐

热门文章

  1. 微信小程序 SKU设计与实现 前端 数据结构分析
  2. 商城-商品规格管理-SPU和SKU数据结构
  3. 指示灯循环控制C语言代码,指示灯循环控制.doc
  4. 飞控手机地面站调试_PX4飞控连接地面站注意事项
  5. AE基础教程(12)——第12章 轨道遮罩
  6. 奇虎360笔试题 最后一个字符
  7. FineReport 基础报表样式
  8. 量化交易——传统技术分析相对强弱指数RSI的原理及实现
  9. 大学计算机基础试题第六章,大学计算机基础第六章作业答案
  10. 一种基于嵌入式的多重识别门禁系统设计方案