知识卡片
字符类中的美元不是串尾锚点
本章[\s$]写在字符类内,含义是空白或字面美元,不是空白或字符串末尾。因此结尾标点可能保留,美元又可能被意外消费;需分别定义边界与是否保留终止符,不把书中现象解释为正确锚点处理。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
原书出处 · 1 处
- · 查看原书依据
Unfortunately, this re.split approach gobbles up (consumes) the sentence-terminating token. Notice how the ellipsis and period at the end of Hello World are missing in the returned list? The splitter only returns the sentence terminator if it is the last character in a document or string. A regular expression that assumes your sentences will end in whitespace does do a good job of ignoring the
参考来源
- 位置:《Natural Language Processing in Action, Second Edition》第11章《信息抽取与知识图谱》(来源项目:a19c7933-4eda-4176-aebd-30fe7e1ad292;源文件:extracted/Natural Language Processing in Action, Second Edition/_epub-src/OEBPS/Text/chapter-11.html)
- 结论依据:摘录中关于字符类中的美元不是串尾锚点的定义、比较或条件支撑卡片;原书表述不严谨的范围已在覆盖记录逐项限定,不把案例结果外推为普遍结论。
- 原始内容:Unfortunately, this re.split approach gobbles up (consumes) the sentence-terminating token. Notice how the ellipsis and period at the end of Hello World are missing in the returned list? The splitter only returns the sentence terminator if it is the last character in a document or string. A regular expression that assumes your sentences will end in whitespace does do a good job of ignoring the