if (FALSE) {
x <- "Robots are evl creatres and deserv exterimanitation."
which_misspelled(x, suggest=FALSE)
which_misspelled(x, suggest=TRUE)
check_spelling(DATA$state)
## browseURL("http://stackoverflow.com/a/24454727/1000343")
terms <- c("accounts", "account", "accounting", "acounting", "acount", "acounts", "accounnt")
set.seed(10)
(fake_text <- unlist(lapply(terms, function(x) {
unbag(sample(c(x, sample(DICTIONARY[[1]], sample(1:5, 1)))))
})))
check_spelling(fake_text)
##============================##
## INTERACTIVE SPELL CHECKING ##
##============================##
## No misspellings found
check_spelling_interactive(DATA$state)
## character method approach (minimal example)
dat <- DATA$state; dat[1] <- "I likedd the cokie icekream"
(o <- check_spelling_interactive(dat))
preprocessed(o)
fixit <- attributes(o)$correct
fixit(dat)
## character method approach (larger example)
m <- check_spelling_interactive(mraja1spl$dialogue[1:75])
preprocessed(m)
fixit <- attributes(m)$correct
fixit(mraja1spl$dialogue[1:75])
## check_spelling method approach
out <- check_spelling(mraja1spl$dialogue[1:75])
(x <- check_spelling_interactive(out))
preprocessed(x)
correct(x)(mraja1spl$dialogue[1:75])
(y <- check_spelling_interactive(out, click=FALSE))
preprocessed(y)
## Examine Methods (?stringdist::stringdist)
strings <- c(
"Robots are evl creatres and deserv exterimanitation kream.",
"I gots me a biggert measrue, tommorrow"
)
meths <- c("osa", "lv", "dl", "hamming", "lcs", "qgram", "cosine", "jaccard", "jw")
stats::setNames(lapply(meths, function(x) check_spelling(strings, method=x)), meths)
}
Run the code above in your browser using DataLab