【发布时间】:2018-08-23 20:07:03
【问题描述】:
我写了以下代码,但它不起作用
replacePunctuation <- function(x) {
gsub("[[:punct:]]+" , " " , x)
}
sms_data_corpus_clean <- tm_map(sms_data_corpus_clean, replacePunctuation)
**I installed and loaded the library tm
注意:目的是避免使用以下示例中的标点符号:
Are you still.....there?
使用
sms_data_corpus_clean <- tm_map(sms_data_corpus_clean, removePunctuation)
我们会得到这样连接的两个词
Are you stillthere
【问题讨论】:
-
我复制了你的函数问题中出现的然后
X = "Are you still.....there?"当我运行replacePunctuation(X)时我得到[1]“你还在吗”的话不是加入。 -
也许你可以试试
gsub("[[:punct:]]{2,}"," ","Are you still.....there?") [1] "Are you still there?"
标签: r regex corpus punctuation