知识卡片
简化去尾规则须说明覆盖边界
示例保留ss结尾,对部分单s结尾去s并剥离引号,可用于展示规则流程,但dishes、heroes或housing未必得到正确规范形。输入、大小写和标点处理也在改变信息;不能凭几例就称已支持一般英文词法。
这张卡片看不懂?
这张卡片已通过人工审查,不再接受失败反馈。
已有反馈 · 0 条
还没有人提交反馈。
在整书笔记中的位置
- · 思维的词元
原书出处 · 1 处
- · 查看原书依据
>>> def stem(phrase): ... return ' '.join([re.findall('^(.*ss|.*?)(s)?$', ... word)[0][0].strip("'") for word in phrase.lower().split()]) >>> stem('houses') 'house' >>> stem("Doctor House's calls") 'doctor house call' The preceding stemmer function follows a few simple rules within that one short regular expression: If a word ends with more than one s, the stem is the word and the suffix is a blank string. If a word ends with a
参考来源
- 位置:《Natural Language Processing in Action, Second Edition》第02章《思维的词元》(来源项目:a19c7933-4eda-4176-aebd-30fe7e1ad292;源文件:extracted/Natural Language Processing in Action, Second Edition/_epub-src/OEBPS/Text/chapter-2.html)
- 结论依据:摘录中关于简化去尾规则须说明覆盖边界的定义、比较或条件支撑卡片;原书表述不严谨的范围已在覆盖记录逐项限定,不把案例结果外推为普遍结论。
- 原始内容:>>> def stem(phrase): ... return ' '.join([re.findall('^(.*ss|.*?)(s)?$', ... word)[0][0].strip("'") for word in phrase.lower().split()]) >>> stem('houses') 'house' >>> stem("Doctor House's calls") 'doctor house call' The preceding stemmer function follows a few simple rules within that one short regular expression: If a word ends with more than one s, the stem is the word and the suffix is a blank string. If a word ends with a