From 3c3c5fd5afbc5d0cba4c423c57da7248713770fa Mon Sep 17 00:00:00 2001 From: SaiSrichandra Date: Fri, 9 Oct 2020 13:04:54 +0530 Subject: [PATCH 1/5] Added the Spell Corrector --- Spelling Corrector/README.md | 23 ++++++++++++++++++++++ Spelling Corrector/SpellCorrector.py | 29 ++++++++++++++++++++++++++++ Spelling Corrector/requirements.txt | 1 + 3 files changed, 53 insertions(+) create mode 100644 Spelling Corrector/README.md create mode 100644 Spelling Corrector/SpellCorrector.py create mode 100644 Spelling Corrector/requirements.txt diff --git a/Spelling Corrector/README.md b/Spelling Corrector/README.md new file mode 100644 index 000000000..f2bb41092 --- /dev/null +++ b/Spelling Corrector/README.md @@ -0,0 +1,23 @@ +# 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` + +Example: +`python SpellCorrector.py Hello, Thank yu for using ths scrpt` + +Output for above code is: + +`Hello, Thank you for using the script` diff --git a/Spelling Corrector/SpellCorrector.py b/Spelling Corrector/SpellCorrector.py new file mode 100644 index 000000000..a83a2efdb --- /dev/null +++ b/Spelling Corrector/SpellCorrector.py @@ -0,0 +1,29 @@ +# 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 + + + +# Fuction for correcting spelling erors + +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() \ No newline at end of file diff --git a/Spelling Corrector/requirements.txt b/Spelling Corrector/requirements.txt new file mode 100644 index 000000000..3f42dc362 --- /dev/null +++ b/Spelling Corrector/requirements.txt @@ -0,0 +1 @@ +textblob \ No newline at end of file From d9db57fccdc0c7b27c201ea2c22085c10b655906 Mon Sep 17 00:00:00 2001 From: SaiSrichandra Date: Fri, 9 Oct 2020 13:15:53 +0530 Subject: [PATCH 2/5] Added the Spell Corrector --- {Spelling Corrector => spellingcorrector}/README.md | 0 {Spelling Corrector => spellingcorrector}/SpellCorrector.py | 0 {Spelling Corrector => spellingcorrector}/requirements.txt | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename {Spelling Corrector => spellingcorrector}/README.md (100%) rename {Spelling Corrector => spellingcorrector}/SpellCorrector.py (100%) rename {Spelling Corrector => spellingcorrector}/requirements.txt (100%) diff --git a/Spelling Corrector/README.md b/spellingcorrector/README.md similarity index 100% rename from Spelling Corrector/README.md rename to spellingcorrector/README.md diff --git a/Spelling Corrector/SpellCorrector.py b/spellingcorrector/SpellCorrector.py similarity index 100% rename from Spelling Corrector/SpellCorrector.py rename to spellingcorrector/SpellCorrector.py diff --git a/Spelling Corrector/requirements.txt b/spellingcorrector/requirements.txt similarity index 100% rename from Spelling Corrector/requirements.txt rename to spellingcorrector/requirements.txt From b974b3e2922bc9032821748a11d05008a79e5734 Mon Sep 17 00:00:00 2001 From: SaiSrichandra Date: Fri, 9 Oct 2020 13:43:14 +0530 Subject: [PATCH 3/5] Made small corrections --- spellingcorrector/README.md | 7 ------- spellingcorrector/SpellCorrector.py | 12 +++++------- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/spellingcorrector/README.md b/spellingcorrector/README.md index f2bb41092..95b5123e7 100644 --- a/spellingcorrector/README.md +++ b/spellingcorrector/README.md @@ -14,10 +14,3 @@ Then you can run the script! ## Instructions to run the script `python SpellCorrector.py text_input` - -Example: -`python SpellCorrector.py Hello, Thank yu for using ths scrpt` - -Output for above code is: - -`Hello, Thank you for using the script` diff --git a/spellingcorrector/SpellCorrector.py b/spellingcorrector/SpellCorrector.py index a83a2efdb..f37268826 100644 --- a/spellingcorrector/SpellCorrector.py +++ b/spellingcorrector/SpellCorrector.py @@ -4,20 +4,17 @@ from textblob import TextBlob import sys - - -# Fuction for correcting spelling erors +# Function for correcting spelling errors def spell_correct(text): - spell = TextBlob(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:]): @@ -25,5 +22,6 @@ def main(): print(after_correction) # Running the main() function + if __name__ == '__main__': - main() \ No newline at end of file + main() From 2b805c4610837bb392f4d2505d4edea1270df774 Mon Sep 17 00:00:00 2001 From: SaiSrichandra Date: Fri, 9 Oct 2020 13:46:41 +0530 Subject: [PATCH 4/5] Made small corrections --- spellingcorrector/SpellCorrector.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spellingcorrector/SpellCorrector.py b/spellingcorrector/SpellCorrector.py index f37268826..3be6b8172 100644 --- a/spellingcorrector/SpellCorrector.py +++ b/spellingcorrector/SpellCorrector.py @@ -6,8 +6,9 @@ # Function for correcting spelling errors + def spell_correct(text): - spell = TextBlob(text) + spell = TextBlob(text) # Using TextBlob.correct() method to correct spelling errors after_correction = spell.correct() return after_correction @@ -24,4 +25,5 @@ def main(): # Running the main() function if __name__ == '__main__': + main() From 38c7374c2a56680744e1bad18139ddc77948803c Mon Sep 17 00:00:00 2001 From: SaiSrichandra Date: Fri, 9 Oct 2020 13:50:15 +0530 Subject: [PATCH 5/5] Made small corrections --- spellingcorrector/SpellCorrector.py | 1 + 1 file changed, 1 insertion(+) diff --git a/spellingcorrector/SpellCorrector.py b/spellingcorrector/SpellCorrector.py index 3be6b8172..43669b0cc 100644 --- a/spellingcorrector/SpellCorrector.py +++ b/spellingcorrector/SpellCorrector.py @@ -24,6 +24,7 @@ def main(): # Running the main() function + if __name__ == '__main__': main()