形势与问题
1.
例:
你有一段话。
sentence这个词用连字符分解为sente-nce。
Imagine you have this sample sentence, which is a very long sente-
nce that has a word being broken down with a hyphen. 2.
如何检测到单词sente-nce 是用连字符分解的,并将其更正为 sentence**?**
注意:
(\w)-(\w) &用$1$2替换,在所有情况下都是行不通的。想象一下你有一个词event-driven,它会变成eventdriven,这是不想要的。--
发布于 2022-08-30 14:13:57
你需要检查这个单词是否属于英语词汇。查找所有匹配项,检查每个单词是否存在于英语词汇中,如果没有,则更改单词。类似于:
import enchant
voc = enchant.Dict("en_US")
word = "sente-nce"
voc.check(word)如果它不是一个词,它会返回假的。
https://stackoverflow.com/questions/73542900
复制相似问题