匹配 R/nlp/spacyr 中的多个字符串
Matching multiple strings in R/nlp/spacyr
我有一个数据框
myDataframe <- data.frame(keyword = c(c("meeting", "laptop"),c("attend a meeting", "fan")))
description <- "I have to attend a meeting."
我必须将描述与数据框中的列关键字和 return“参加会议”相匹配。
是否有任何解决方案来获得特定的输出
使用 grepl
将 return myDataframe
中的关键字包含在 description
中
myDataframe <- data.frame(keyword = c(c("meeting", "laptop"),c("attend a meeting", "fan")))
description <- "I have to attend a meeting."
found <- as.logical(lapply(myDataframe$keyword ,
function(x) grepl(x , description)))
myDataframe[found , ]
#> [1] "meeting" "attend a meeting"
由 reprex package (v2.0.1)
创建于 2022-06-02
我有一个数据框
myDataframe <- data.frame(keyword = c(c("meeting", "laptop"),c("attend a meeting", "fan")))
description <- "I have to attend a meeting."
我必须将描述与数据框中的列关键字和 return“参加会议”相匹配。 是否有任何解决方案来获得特定的输出
使用 grepl
将 return myDataframe
中的关键字包含在 description
myDataframe <- data.frame(keyword = c(c("meeting", "laptop"),c("attend a meeting", "fan")))
description <- "I have to attend a meeting."
found <- as.logical(lapply(myDataframe$keyword ,
function(x) grepl(x , description)))
myDataframe[found , ]
#> [1] "meeting" "attend a meeting"
由 reprex package (v2.0.1)
创建于 2022-06-02