Package: manual-spellchecker
Manual Spell CheckerA manual spell checkerbuilt onpyenchantthat allows you to swiftly correct misspelled words.Why does this exist?While I was working on a text based multi-class classification competition, I noticed that the data contained a lot of misspelled words, errors which automated spell check packages out there couldn't fix. This was because the data had been compiled based on a survey of people who weren't native English speakers. As the there weren't many samples in the dataset (~1000), I decided to write some code for automated detection of spelling errors which I could then fix manually, and thus, this package was born.How to install?pip install manual_spellcheckerFeaturesAll features as provided bypyenchantQuickly analyze and get a list of all misspelled wordsCan replace, skip and delete misspelled wordsUse your favourite tokenizer for splitting wordsReplaced misspelled words via provided suggestions by simply typing in their indicesCan checkpoint current set of correctionsContexualized pretty printing for easy visual correction (works on both command line and notebook)Functions and Parameters# Initialize the spell checking object__init__(dataframe,column_names,tokenizer=None,num_n_words_dis=5,save_path=None)dataframe- Takes a pandas dataframe as inputcolumn_names- Pass the column name(s) upon which you want to perform spelling correctiontokenizer=None- Pass your favourite tokenizer like nltk or spacy, etc. (Default: splits on space)num_n_words_dis=5- This decides how many neighbouring words to display on either side of the errorsave_path=None- If a save path is provided, the final corrected dataframe is saved as a csv. (Default: the dataframe is not saved but returned)# For quick analysis of all the misspelled wordsspell_check()# Returns a list of all the misspelled wordsget_all_errors()# Starts the process of correcting erroneous wordscorrect_words()Important Note:Type -999 into the input box to stop the error correction and save the current progress (if save_path is provided)Simply press enter if you want to skip the current wordType in "" or '' in the input box to delete a misspelled wordUsageHow to import?frommanual_spellcheckerimportspell_checkerQuick analysis of the total number of errors# Read the datadf=pd.read_csv("Train.csv")# Initialize the modelob=spell_checker(df,"text")# Quick analysisob.spell_check()Multiple columns can be passed for spelling correction# Read the datadf=pd.read_csv("Train.csv")# Initialize the modelob=spell_checker(df,["text","label"])# Quick analysisob.spell_check()You can pass your own tokenizers# Import nltk's word tokenizerfromnltkimportword_tokenize# Read the datadf=pd.read_csv("Train.csv")# Initialize the modelob=spell_checker(df,"text",word_tokenize)# Quick analysisob.spell_check()Get a list of all the errors# Read the datadf=pd.read_csv("Train.csv")# Initialize the modelob=spell_checker(df,"text")# Quick analysis. This needs to be performed before getting all errorsob.spell_check()# Returns a list of all errorsob.get_all_errors()Make corrections# Read the datadf=pd.read_csv("Train.csv")# Initialize the modelob=spell_checker(df,"text")# Start correctionsob.correct_words()To savedf=pd.read_csv("Train.csv")# Initialize the modelob=spell_checker(df,"text",save_path="correct_train_data.csv")Future IdeasWill be adding automated, contextual error correctionsFeature RequestDrop me an email atatif.hit.hassan@gmail.comif you want any particular feature