A Mini Search Engine project developed as part of my 2nd Semester DSA Lab Project (BS AI, NFC IET Multan).
It demonstrates core Data Structures and Algorithms (DSA) concepts such as:
- Stack (for search history navigation)
- Inverted Index / Hash Map (for efficient keyword-based searching)
- String processing & searching algorithms
- β Keyword-based Search β finds documents containing query terms
- β Ranked Results β based on frequency of query terms
- β
Search History (UNDO) β supports
backcommand just like a browser - β
Search History (REDO) β supports
nextcommand just like a browser - β
Document Viewer β open
.txtfiles directly from search results - β
Automatic Crawler β indexes all
.txtfiles in thedocuments/folder - β Clean modular structure for GitHub
Mini-Search-Engine/
β
βββ stack.py # Stack implementation (push, pop, peek, empty)
βββ index.py # Inverted Index implementation
βββ search.py # Search Engine logic
βββ main.py # Entry point for running the project
β
βββ documents/ # Folder containing sample text files
β βββ doc1.txt
β βββ doc2.txt
β βββ ...
β
βββ README.md # Project documentation- The program scans the
documents/folder and builds an inverted index. - When the user searches, queries are cleaned (lowercased, punctuation removed, split into words).
- Matching documents are ranked by query word frequency.
- The query is pushed onto the Stack (history).
- If the user types back, the last query is popped and the previous one is shown again.
- The user can open a result to see the full content of the file.
python main.pyIndex built with 5 documents.
Enter search query, 'back','next', 'show', or 'quit': ai
[Stack] Pushed: ai
Searching for: 'ai'
Found 1 document(s):
1. doc5.txt | Score: 2
Enter document number to open, or 'continue': continue
Enter search query, 'back','next', 'show', or 'quit': cs
[Stack] Pushed: cs
Searching for: 'cs'
Found 1 document(s):
1. doc2.txt | Score: 1
Enter document number to open, or 'continue': continue
Enter search query, 'back','next', 'show', or 'quit': back
[Stack] Popped: cs
[Stack] Pushed: cs
Back to: 'ai'
1. doc5.txt | Score: 2
Enter document number to open, or 'continue': next
Please enter a valid number or 'continue'.
Enter document number to open, or 'continue': continue
Enter search query, 'back','next', 'show', or 'quit': quit
Goodbye!
-
π Course: Data Structures & Algorithms (DSA)
-
π Semester: 2nd Semester, BS Artificial Intelligence
-
ποΈ University: NFC IET Multan
-
π¨βπ» Student: Muawiya Amir
-
π¨βπ» Muawiya (Team Leader)
-
π¨βπ» M. Umar
- Add synonym & fuzzy matching for queries
- Implement OR / NOT search operators
- Enhance ranking with TF-IDF instead of simple counts
- Build a GUI or Web-based interface