假设我有以下句子:
总之,我需要一个能够去除一般标点符号的代码,包括 "'s",但要保留原始格式的否定词。
有人可以帮助我吗?
谢谢!
s = c("I don't want to remove punctuation for negations. Instead, I want to remove only general punctuation. For example, keep I wouldn't like it but remove Inter's fan or Man city's fan.")
我希望能够获得以下结果:
"I don't want to remove punctuation for negations Instead I want to remove only general punctuation For example keep I wouldn't like it but remove Inter fan or Man city fan."
如果我简单地使用以下代码,那么我会删除否定中的两个's'和一个撇号。
s %>% str_replace_all("['']s\\b|[^[:alnum:][:blank:]@_]"," ")
"I don t want to remove punctuation for negations Instead I want to remove only general punctuation For example keep I wouldn t like it but remove Inter fan or Man city fan "
总之,我需要一个能够去除一般标点符号的代码,包括 "'s",但要保留原始格式的否定词。
有人可以帮助我吗?
谢谢!
"'t"
,也许只需使用固定匹配删除"'s"
? - zx8754"'t"
。 - Rollo99