diff --git a/spellingcorrector/README.md b/spellingcorrector/README.md new file mode 100644 index 000000000..95b5123e7 --- /dev/null +++ b/spellingcorrector/README.md @@ -0,0 +1,16 @@ +# SpellCorrector +This is a basic spelling corrector which works on command line. You have to give text input as a command line argument +## Prerequisites + +**Python 3.8.x** +**textblob package** + +Install the requirements: + +`python -m pip install -r requirements.txt --user` + +Then you can run the script! + +## Instructions to run the script + +`python SpellCorrector.py text_input` diff --git a/spellingcorrector/SpellCorrector.py b/spellingcorrector/SpellCorrector.py new file mode 100644 index 000000000..43669b0cc --- /dev/null +++ b/spellingcorrector/SpellCorrector.py @@ -0,0 +1,30 @@ +# Title :- Spell Corrector +# The Spell Corrector is an application which takes text input from the user and corrects spelling errors in it + +from textblob import TextBlob +import sys + +# Function for correcting spelling errors + + +def spell_correct(text): + spell = TextBlob(text) + # Using TextBlob.correct() method to correct spelling errors + after_correction = spell.correct() + return after_correction + +# Takes text input from user and call the spell_correct() function + + +def main(): + after_correction = "" + for text in map(spell_correct, sys.argv[1:]): + after_correction += str(text) + ' ' + print(after_correction) + +# Running the main() function + + +if __name__ == '__main__': + + main() diff --git a/spellingcorrector/requirements.txt b/spellingcorrector/requirements.txt new file mode 100644 index 000000000..3f42dc362 --- /dev/null +++ b/spellingcorrector/requirements.txt @@ -0,0 +1 @@ +textblob \ No newline at end of file