Skip to content

Latest commit

Β 

History

History
120 lines (88 loc) Β· 3.33 KB

File metadata and controls

120 lines (88 loc) Β· 3.33 KB

πŸ” Mini Search Engine with Stack

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

✨ Features

  • βœ… Keyword-based Search β†’ finds documents containing query terms
  • βœ… Ranked Results β†’ based on frequency of query terms
  • βœ… Search History (UNDO) β†’ supports back command just like a browser
  • βœ… Search History (REDO) β†’ supports next command just like a browser
  • βœ… Document Viewer β†’ open .txt files directly from search results
  • βœ… Automatic Crawler β†’ indexes all .txt files in the documents/ folder
  • βœ… Clean modular structure for GitHub

πŸ—‚οΈ Project Structure

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

⚑ How It Works

  • 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.

▢️ Usage

Run the program:

python main.py

Example Session:

Index 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!

🏫 Academic Info

  • πŸ“– Course: Data Structures & Algorithms (DSA)

  • πŸŽ“ Semester: 2nd Semester, BS Artificial Intelligence

  • πŸ›οΈ University: NFC IET Multan

  • πŸ‘¨β€πŸ’» Student: Muawiya Amir


πŸ‘₯ Team Members

  • πŸ‘¨β€πŸ’» Muawiya (Team Leader)

  • πŸ‘¨β€πŸ’» M. Umar


πŸš€ Future Improvements

  • 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