我目前正在处理一个大型数据框,每行包含大量文本,并且希望使用包有效地识别和替换每个句子中拼写错误的单词hunspell。我能够识别出拼写错误的单词,但不知道如何hunspell_suggest在列表上进行操作。
这是数据框的示例:
df1 <- data.frame("Index" = 1:7, "Text" = c("A complec sentence joins an independet",
"Mary and Samantha arived at the bus staton before noon",
"I did not see thm at the station in the mrning",
"The participnts read 60 sentences in radom order",
"how to fix mispelled words in R languge",
"today is Tuesday",
"bing sports quiz"))
Run Code Online (Sandbox Code Playgroud)
我将文本列转换为字符,并用于hunspell识别每行中拼写错误的单词。
library(hunspell)
df1$Text <- as.character(df1$Text)
df1$word_check <- hunspell(df1$Text)
Run Code Online (Sandbox Code Playgroud)
我试过
df1$suggest <- hunspell_suggest(df1$word_check)
Run Code Online (Sandbox Code Playgroud)
但它一直给出这个错误:
Error in hunspell_suggest(df1$word_check) …Run Code Online (Sandbox Code Playgroud)