How to replace specific misspelled words on a list from a list of correct spelling words

I'm having trouble replacing misspelling words from a list of correct spelling words.

I have tried calculating the distance between the words using stringdist but it didn't work. Please advise. Thank you.

Here are my 2 tibbles:

word_list = tibble(word_list = list("guest lists", "movie liat", "show lixt", "movie tixket", "airlines tickek", "passenger tickat lixt")

correct_spelling = tibble(correct_spelling = list("list", "ticket")

I hope to achieve something like this:

correct_word_list = tibble(correct_movie_list = list("guest list", "movie list", "show list", "movie ticket", "airlines ticket", "passenger ticket list")

Hi @cheklapkok, what do you mean by 'didn't work'? It would help to provide the code you tried and any output you got.

Also, my hunch is that it might help to split your word_list strings to contain a single word. For example, this might get you started:

library(tidyverse)
word_list = c("guest lists", "movie liat", "show lixt", "movie tixket", "airlines tickek", "passenger tickat lixt")
correct_spelling = c("list", "ticket")
                  
split_words <- stringi::stri_split_regex(word_list[1], pattern = ' ', simplify = TRUE)

adist(split_words, correct_spelling)
#>      [,1] [,2]
#> [1,]    3    5
#> [2,]    1    5

Created on 2019-02-01 by the reprex package (v0.2.1)

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.