Hi everyone...I should search some words in this dataframe.
data <- data.frame(stringsAsFactors = FALSE,
Id_text = c("1", "2", "3"),
Text = c("What I really feel is necessary is that the black people in this country wil have to upset this apple cart. We can no longer ignore the fact that America is not the... land of the free and the home of the brave",
"This Article shall not apply to pineapples produced in the Azores.", "Particularly suitable for watering vegetables, pineapples, sugar cane and bananas")
)
dictionary <- c("apple", "pineapple", "pine", "pineapples")
So I run this:
data %>%
bind_cols(dictionary %>%
set_names() %>%
map_dfc(~str_detect(data$Text, .x)) %>%
mutate_all(as.numeric)) %>%
as_tibble()
So I have 2 problems:
- the word "apple" match with "pineapple"
- the word "pine" match with "pineapple"
I could use "\b" or boundary function but i have 20 different dictionaries that i will import from excel document and I can 't figure it out.
Thank you!