У меня есть список слов, и я ищу слова, которые есть в тексте. В результате в последнем столбце всегда находится поиск шаблонов. Я ищу точное совпадение, которое есть в словах. Не комбинации. Для первых трех записей это не должно быть найдено. Пожалуйста, направьте, где я иду не так.
col_1 <- c(1,2,3,4,5)
col_2 <- c("work instruction change",
"technology npi inspections",
" functional locations",
"Construction has started",
" there is going to be constn coon")
df <- as.data.frame(cbind(col_1,col_2))
df$col_2 <- tolower(df$col_2)
words <- c("const","constn","constrction","construc",
"construct","construction","constructs","consttntype","constypes","ct","ct#",
"ct2"
)
pattern_words <- paste(words, collapse = "|")
df$result<- ifelse(str_detect(df$col_2, regex(pattern_words)),"Found","Not Found")