【发布时间】:2019-08-28 20:39:40
【问题描述】:
我目前正在处理每行包含大量文本的大型数据框,并希望使用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"))
我将文本列转换为字符,并使用hunspell 来识别每一行中的拼写错误。
library(hunspell)
df1$Text <- as.character(df1$Text)
df1$word_check <- hunspell(df1$Text)
我试过了
df1$suggest <- hunspell_suggest(df1$word_check)
但它总是给出这个错误:
Error in hunspell_suggest(df1$word_check) :
is.character(words) is not TRUE
我是新手,所以我不确定使用hunspell_suggest 函数的建议列会如何。任何帮助将不胜感激。
【问题讨论】:
标签: r spell-checking hunspell