diff --git a/Spell-Sense/README.md b/Spell-Sense/README.md new file mode 100644 index 0000000..2716c58 --- /dev/null +++ b/Spell-Sense/README.md @@ -0,0 +1,49 @@ +# Spell-Sense: Advanced Spell Checker + +Spell-Sense is a professional, modular Python application that provides real-time spelling suggestions. Built with `Tkinter` and `TextBlob`, it improves upon basic implementations by adding robust error handling and a clean, user-friendly interface. + +## Features +- Smart Validation: Detects empty inputs and prevents unnecessary processing. +- Color-Coded Feedback: Uses visual cues (Green for success, Blue for suggestions, Red for errors). +- Modular Design: Separation of concerns between UI logic and processing logic. +- Keyboard Friendly: Press `Enter` to check spelling instantly without clicking. +- Auto-Focus: The cursor starts in the input box for immediate typing. + +## Project Structure +/Spell-Sense/ +├── main.py # Entry point and UI (Tkinter) +├── logic.py # Core NLP logic (TextBlob) +├── requirements.txt # Dependency list +└── README.md # Documentation + +🚀 Installation & Setup +Prerequisites +Python 3.6 or higher + +Setup +Navigate to your project directory: + +Bash +cd Spell-Sense +Install the required dependencies: + +Bash +pip install -r requirements.txt +🛠️ Usage +Run the script from your terminal: + +Bash +python main.py +Type a word into the input box. + +Press Enter or click Check. + +View the suggestion or success message below. + +Click Reset to clear the fields. + +📝 Credits +This project was developed as an enhanced alternative to basic scripts in this repository. It focuses on modularity, error handling, and improved User Experience (UX). + +License +This project is open-source and intended for educational use. \ No newline at end of file diff --git a/Spell-Sense/logic.py b/Spell-Sense/logic.py new file mode 100644 index 0000000..38bd71c --- /dev/null +++ b/Spell-Sense/logic.py @@ -0,0 +1,12 @@ +from textblob import TextBlob + +def get_correction(text): + if not text.strip(): + return None, False + + blob = TextBlob(text) + corrected = str(blob.correct()) + + # Check if the original matches the corrected version + is_correct = text.lower().strip() == corrected.lower().strip() + return corrected, is_correct \ No newline at end of file diff --git a/Spell-Sense/main.py b/Spell-Sense/main.py new file mode 100644 index 0000000..0ab991f --- /dev/null +++ b/Spell-Sense/main.py @@ -0,0 +1,55 @@ +import tkinter as tk +from logic import get_correction + +class SpellCheckerApp: + def __init__(self, root): + self.root = root + self.root.title("Spell Checker Pro") + self.root.geometry("400x300") + self.root.configure(bg='#f7f7f7') + + self.setup_ui() + self.root.bind('', lambda e: self.process_text()) + + def setup_ui(self): + # Label + tk.Label(self.root, text="Pro Spell Checker", font=("Arial", 14, "bold"), bg='#f7f7f7').pack(pady=10) + + # Entry + self.input_entry = tk.Entry(self.root, font=("Arial", 12), width=30) + self.input_entry.pack(pady=10) + self.input_entry.focus_set() + + # Buttons + btn_frame = tk.Frame(self.root, bg='#f7f7f7') + btn_frame.pack(pady=10) + + self.check_btn = tk.Button(btn_frame, text="Check", command=self.process_text, bg='#4CAF50', fg='white', width=10) + self.check_btn.pack(side=tk.LEFT, padx=5) + + self.reset_btn = tk.Button(btn_frame, text="Reset", command=self.reset_fields, bg='#f44336', fg='white', width=10) + self.reset_btn.pack(side=tk.LEFT, padx=5) + + # Result display + self.result_label = tk.Label(self.root, text="", font=("Arial", 11), bg='#f7f7f7', wraplength=350) + self.result_label.pack(pady=20) + + def process_text(self): + text = self.input_entry.get() + corrected, is_correct = get_correction(text) + + if corrected is None: + self.result_label.config(text="Please enter a word!", fg="orange") + elif is_correct: + self.result_label.config(text=f"✔ '{text}' is spelled correctly!", fg="green") + else: + self.result_label.config(text=f"✖ Suggestion: {corrected}", fg="blue") + + def reset_fields(self): + self.input_entry.delete(0, tk.END) + self.result_label.config(text="") + +if __name__ == "__main__": + root = tk.Tk() + app = SpellCheckerApp(root) + root.mainloop() \ No newline at end of file diff --git a/Spell-Sense/requirements.txt b/Spell-Sense/requirements.txt new file mode 100644 index 0000000..3f42dc3 --- /dev/null +++ b/Spell-Sense/requirements.txt @@ -0,0 +1 @@ +textblob \ No newline at end of file