Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,51 +1,87 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
|
| 3 |
-
This is a simple yet intelligent
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 4 |
|
| 5 |
---
|
| 6 |
|
| 7 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
|
|
|
|
|
|
|
|
|
| 14 |
|
| 15 |
-
|
| 16 |
-
- A CSV file (`clean_basic_conversations.csv`) is used as the chatbot's memory.
|
| 17 |
-
- Each known query is broken into thematic roles.
|
| 18 |
-
- String similarity is calculated (using `difflib`) between roles.
|
| 19 |
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
|
|
|
|
|
|
| 23 |
|
| 24 |
---
|
| 25 |
|
| 26 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
|
| 33 |
---
|
| 34 |
|
| 35 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
| `clean_basic_conversations.csv` | Knowledge base used by the chatbot |
|
| 42 |
-
| `requirements.txt` | Required Python libraries |
|
| 43 |
-
| `README.md` | Project documentation |
|
| 44 |
|
| 45 |
---
|
| 46 |
|
| 47 |
-
##
|
|
|
|
|
|
|
| 48 |
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
|
|
|
| 1 |
+
---
|
| 2 |
+
title: Context-Aware Chatbot
|
| 3 |
+
emoji: π§
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: indigo
|
| 6 |
+
sdk: gradio
|
| 7 |
+
sdk_version: 3.50.2
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
license: apache-2.0
|
| 11 |
+
---
|
| 12 |
+
|
| 13 |
+
# π€ Context-Aware Chatbot using Thematic Roles and Similarity Matching
|
| 14 |
|
| 15 |
+
This project is a simple yet intelligent chatbot that uses **Natural Language Processing (NLP)** to understand user input and reply contextually. It combines:
|
| 16 |
+
|
| 17 |
+
- π§ **Thematic Role Extraction** using `spaCy` (to identify subjects, objects, and verbs)
|
| 18 |
+
- π **String Similarity Matching** using `difflib` (to compare user input with a knowledge base)
|
| 19 |
+
- π¬ A custom **conversation dataset** with real-life queries and responses
|
| 20 |
+
- π A **Gradio interface** deployed on Hugging Face Spaces
|
| 21 |
|
| 22 |
---
|
| 23 |
|
| 24 |
+
## π Features
|
| 25 |
+
- Understands context using subject, object, and verb extraction
|
| 26 |
+
- Matches queries based on thematic roles rather than plain keywords
|
| 27 |
+
- Provides explanations for how the response was selected
|
| 28 |
+
- Interactive and beginner-friendly web interface
|
| 29 |
+
- Can be updated easily by editing the CSV knowledge base
|
| 30 |
|
| 31 |
+
---
|
| 32 |
|
| 33 |
+
## π§© How It Works
|
| 34 |
+
1. The user types a sentence (e.g., "Who are you?")
|
| 35 |
+
2. The chatbot extracts thematic roles (subject, object, verb)
|
| 36 |
+
3. It compares these roles with each query in the CSV using string similarity
|
| 37 |
+
4. If the similarity score crosses a threshold, it returns the best matching response
|
| 38 |
+
5. If no match is found, it responds with a fallback message
|
| 39 |
|
| 40 |
+
---
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
+
## π Files
|
| 43 |
+
- `app.py` β Main application file (Gradio interface + NLP logic)
|
| 44 |
+
- `clean_basic_conversations.csv` β Custom dataset of conversations
|
| 45 |
+
- `requirements.txt` β Python dependencies
|
| 46 |
+
- `README.md` β Project description and Hugging Face config
|
| 47 |
|
| 48 |
---
|
| 49 |
|
| 50 |
+
## π¦ Installation (for local testing)
|
| 51 |
+
```bash
|
| 52 |
+
pip install -r requirements.txt
|
| 53 |
+
python app.py
|
| 54 |
+
```
|
| 55 |
|
| 56 |
+
---
|
| 57 |
+
|
| 58 |
+
## πΌ Example Conversation
|
| 59 |
+
**You:** Who created you?
|
| 60 |
+
**Bot:** I was created by two AIML students named Rohit and Ankur.
|
| 61 |
+
|
| 62 |
+
**You:** What do you do?
|
| 63 |
+
**Bot:** I help answer questions using simple natural language understanding.
|
| 64 |
|
| 65 |
---
|
| 66 |
|
| 67 |
+
## π§ Technologies Used
|
| 68 |
+
- Python 3
|
| 69 |
+
- spaCy (NLP parsing)
|
| 70 |
+
- difflib (string similarity)
|
| 71 |
+
- pandas (data handling)
|
| 72 |
+
- Gradio (interface)
|
| 73 |
|
| 74 |
+
---
|
| 75 |
+
|
| 76 |
+
## π License
|
| 77 |
+
This project is released under the **MIT License**. You are free to use, modify, and distribute it for educational or research purposes.
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
---
|
| 80 |
|
| 81 |
+
## π¨π»βπ» Created By
|
| 82 |
+
- Rohit Gomes
|
| 83 |
+
- Ankur Halder
|
| 84 |
|
| 85 |
+
---
|
| 86 |
+
|
| 87 |
+
Enjoy chatting! π€
|