0
Я выяснил позиции приближенных machtes в targetframe
с помощью word.library
со следующим кодом:Regmatches более двух списков в R
tragetframe <- data.frame(words= c("Important Words",
"I would also Importante worde of thes substring",
"No mention of this crazy sayingsys"))
word.library <- data.frame(mainword = c("important word",
"crazy sayings"),
keyID =c("2000", "3000"))
##find position
find <- function(word.library, tragetframe) {
aregexec(word.library, tragetframe, max.distance = 0.1)
}
positions <- lapply(word.library[,1], find, tragetframe[,1])
После этого я хочу, чтобы извлечь совпавшие подстроки, но это делает не работает:
extract <- function(tragetframe, positions) {
regmatches(tragetframe, positions)
}
extracted_machtes <- lapply(tragetframe[,1], extract, positions)
Надеюсь, кто-то может помочь мне найти решение.