From ae4d04afb992c9cf5f03492f8359c66343ae105f Mon Sep 17 00:00:00 2001 From: Jay Paliwal Date: Sat, 10 Oct 2020 10:33:00 +0530 Subject: [PATCH] added spell_corrector with linting --- spell_corrector/README.md | 2 ++ spell_corrector/requirements.txt | 1 + spell_corrector/spell_corrector.py | 23 +++++++++++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 spell_corrector/README.md create mode 100644 spell_corrector/requirements.txt create mode 100644 spell_corrector/spell_corrector.py diff --git a/spell_corrector/README.md b/spell_corrector/README.md new file mode 100644 index 000000000..756b55952 --- /dev/null +++ b/spell_corrector/README.md @@ -0,0 +1,2 @@ +# Spelling Corrector + Just select a text file from the tkinter dialogue box and the spellings will be corrected in the file. \ No newline at end of file diff --git a/spell_corrector/requirements.txt b/spell_corrector/requirements.txt new file mode 100644 index 000000000..6cf83efe8 --- /dev/null +++ b/spell_corrector/requirements.txt @@ -0,0 +1 @@ +1. textblob \ No newline at end of file diff --git a/spell_corrector/spell_corrector.py b/spell_corrector/spell_corrector.py new file mode 100644 index 000000000..a27ae37a5 --- /dev/null +++ b/spell_corrector/spell_corrector.py @@ -0,0 +1,23 @@ +from textblob import TextBlob +from tkinter import Tk +from tkinter import filedialog + +gui = Tk() +gui.filename = filedialog.askopenfilename(initialdir="/", + title="Select file", + filetypes=(("txt files", + ".txt"), + ("all files", ".*"))) +f = open(gui.filename, 'r') +s = [] +for i in f: + s.append(i) +f.close() +for i in range(len(s)): + s[i] = TextBlob(s[i]) + s[i] = s[i].correct() +f = open(gui.filename, 'w') +for i in range(len(s)): + s[i] = str(s[i]) + f.write(s[i]) +f.close()