r - 在 R 中进行文本分析,但我无法找到删除“s”或其他缩写的方法
问题描述
我正在尝试从我的文本数据中删除 S 和其他缩写字母。我正在使用的当前预处理代码是这样的:
x<- (demtweets$Tweet)
x <- paste(unlist(x), collapse =" ")
x <- stringi::stri_trans_general(x, "latin-ascii")
x<- gsub(" '[A-z] ", " ", x)
x <- gsub("&", "", x)
x <- gsub("(RT|via)((?:\\b\\W*@\\w+)+)", "", x)
x <- gsub("@\\w+", "", x)
x <- gsub("[[:punct:]]", "", x)
x <- gsub("[[:digit:]]", "", x)
x <- gsub("http\\w+", "", x)
x <- gsub("[ \t]{2,}", "", x)
x <- gsub("^\\s+|\\s+$", "", x)
x <- replace_contraction(x, contraction.key = lexicon::key_contractions,
ignore.case = TRUE)
x <- replace_contraction(x,
contraction = qdapDictionaries::contractions, replace = NULL,
ignore.case = TRUE)
xdfm <-dfm(x, stem = F, remove_punct = T, tolower = T, remove_twitter = T, remove_numbers = TRUE, remove = c(stopwords("english"), "http","https","rt", "t.co"))
textplot_wordcloud(xdfm, min_count = 6, random_order = FALSE,
rotation = .25,
color = RColorBrewer::brewer.pal(8, "Dark2"))
topfeatures(xdfm, 100)
`
这些命令似乎都没有解决这个问题。有什么帮助吗?
解决方案
推荐阅读
- struct - 没有从实现 Rust 特征的结构推断出特征?
- controller - Phoenix - 控制器和视图之间的回调操作
- apache-kafka - 在同一个 Spring Kafka 应用程序中读取 JSON 和 String
- java - 如何从Java中的两个超类继承属性
- c++ - 字符串函数不会返回字符串
- mybatis - 如何在xml文件中自定义一个字符而不是$或#?
- javascript - 多次调用graphql突变后保持多个加载状态
- swift - 共享扩展将选定的文本传递给 textview
- azure - 如何获取流音频转换结果的开始时间和结束时间?
- python - PIP install rasa-x 不工作并且 pip 降级