python中是否有任何方法可以自动更正单列excel文件的多行中的拼写错误?

我正在为一个大学项目进行情感分析。我有一个名为“ comments”的“ column”的excel文件,它具有“ 1000行”。这些行中的句子有拼写错误,为了进行分析,我需要更正它们。我不知道如何处理这个问题,这样我就可以使用python代码在正确的句子中进行排序。

我发现的所有方法都是纠正一个单词的拼写错误,而不是句子,也不是在100行的列级别。

CHEN123NBA 回答:python中是否有任何方法可以自动更正单列excel文件的多行中的拼写错误?

您可以使用Spellchecker来做您的事情

import pandas as pd
from spellchecker import SpellChecker

spell  = SpellChecker()

df = pd.DataFrame(['hooww good mrning playing fotball studyiing hard'],columns = ['text'])

def spell_check(x):
    correct_word = []
    mispelled_word = x.split()
    for word in mispelled_word:
        correct_word.append(spell.correction(word))
    return ' '.join(correct_word)


df['spell_corrected_sentence'] = df['text'].apply(lambda x: spell_check(x))

enter image description here

,

enter image description here但我必须在大型数据集上进行工作(如您在数据集中观察到的[2])。当我尝试将textblob库用于相同的库时,它会像“ bihday”更改为“ midday”一样。 如何修复这类错误。

本文链接:https://www.f2er.com/3162780.html

大家都在问