【发布时间】:2014-06-03 11:50:08
【问题描述】:
我正在处理非结构化数据(文本)。 我想用一些关键词和关键词组合标记数据。
我无法使用单词组合标记数据。我想知道“欺诈”和“误卖”发生在哪里。
我尝试使用 qdap 包 我能够用 OR 条件而不是 AND 条件标记这两个词
下面是我使用的代码
library (qdap)
df<- read.csv (file.choose(),header=T)
####cleaning of text
df$Comment<- strip(df$Comment)##remove capitalization and punctuation
df$Comment<- clean (df$Comment)
df$Comment<- scrubber(df$Comment)
df$Comment<- qprep(df$Comment)
df$Comment<-replace_abbreviation(df$Comment)
terms <- list(
" fraud ",
" refund "," cheat ", " cancellation ", "missold", "delay",
combo1= qcv(fraud,missold) )
df2<-with (df, termco(df$Comment, df$Comment, terms))[["raw"]]###tagging of data with key words
df3<- merge (df, df2, by="Comment")
我正在使用保险公司的投诉数据 我的变量是
- 投诉日期
- 品牌反对者抱怨
- 评论(投诉)
【问题讨论】:
-
grep(paste(terms, collapse="|"), df$Comment)中的正则表达式呢? -
嗨,lukeA,我想将这些关键词和组合(所有这些都说欺诈和错售一起)标记回数据文件,以便我可以分析这些案例的概况
-
对不起,我不明白。请提供示例数据并显示结果应该是什么样子。
-
并且在示例输出中,我想要新列,其中包含发生这些组合的每一行的标签dl.dropboxusercontent.com/u/46021747/sample%20output.xlsx