labs <- c("a [of b in c]", "d [from Coal mines in USA]")
labs
split <- split_noun_pp(labs)
split
paste_noun_pp(split)
# Also works in a data frame
df <- tibble::tibble(labels = c("a [in b]", "c [of d into USA]",
"e [of f in g]", "h [-> i in j]"))
recombined <- df %>%
dplyr::mutate(
splits = split_noun_pp(labels),
recombined = paste_noun_pp(splits)
)
all(recombined$labels == recombined$recombined)
Run the code above in your browser using DataLab