我从某些文本中删除短字和长字的代码是:
# Remove Words based on lowerCutOff & upperCutOff
removeByLength<- function(text,lowerCutOff=2,upperCutOff=12){
text<- gsub("\\b[a-zA-Z0-9]{1,lowerCutOff}\\b|\\b[a-zA-Z0-9]{upperCutOff,}\\b"," ",text)
return(text)
}
如何在不硬编码上下截止点的情况下实现所需的功能?