Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

patilavinash0208/Inverted_Search

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔍 Inverted Search

A high-performance word indexing and search engine built in C — powered by Hash Tables and Linked Lists.


📌 Overview

Inverted Search is a Data Structures project developed in C that efficiently indexes and searches words across multiple text files.

The project implements an Inverted Index using Hashing and Linked Lists to provide:

  • ⚡ Fast word lookup
  • 📊 Word occurrence tracking
  • 📁 Multi-file search support

✨ Features

Feature Description
🗄️ Create Database Build a searchable index from multiple text files
🔎 Search Words Find any word across all indexed files instantly
📈 Frequency Tracking Track how often a word appears in each file
🔄 Update Database Add new files without losing existing data
💾 Save Database Persist the database to disk in a structured format
📂 Load Database Reconstruct the full database from a backup file
🧾 Display Database View the complete indexed database
✅ Duplicate Validation Prevents the same file from being indexed twice

🛠️ Technologies Used

  • C Programming
  • Hash Tables
  • Linked Lists
  • Dynamic Memory Allocation
  • File Handling

🏗️ Data Structure Design

🗂️ Hash Table

The database uses a hash table of size 27:

Index Stores
0 – 25 Words starting with az
26 Words starting with special characters or numbers

🔷 Main Node

Stores the word, file count, and links to sub-nodes.

typedef struct Main
{
    char word[25];
    int file_count;
    S_node *sub_link;
    struct Main *main_link;
} M_node;

🔹 Sub Node

Stores the filename and word frequency for a specific file.

typedef struct Sub
{
    int word_count;
    char filename[20];
    struct Sub *sub_link;
} S_node;

🔄 Project Flow

📄 Input Files
      │
      ▼
✅ Validate Files
      │
      ▼
🗄️ Create Database
      │
      ▼
#️⃣ Hash Table Generation
      │
      ▼
🔠 Word Indexing
      │
      ▼
🔎 Search / 🖥️ Display / 💾 Save / 🔄 Update

📋 Menu Operations

╔══════════════════════════╗
║     INVERTED SEARCH      ║
╠══════════════════════════╣
║  1. Create Database      ║
║  2. Display Database     ║
║  3. Save Database        ║
║  4. Search               ║
║  5. Update Database      ║
║  6. Load Database        ║
║  7. Exit                 ║
╚══════════════════════════╝

⚙️ How It Works

🗄️ Create Database

  • Reads words from one or more input text files
  • Calculates hash index based on the first character of each word
  • Creates Main Nodes (per word) and Sub Nodes (per file)
  • Tracks word frequency per file

🔍 Search

  • Computes the hash index for the search term
  • Traverses the corresponding linked list chain
  • Displays:
    • Number of files containing the word
    • Frequency of the word in each file

🔄 Update Database

  • Accepts new text files to index
  • Validates for duplicate files
  • Merges new data into the existing database seamlessly

💾 Save Database

Persists the full database to a text file using a structured delimiter format:

#0;apple;2;file1.txt;3;file2.txt;5;#

📂 Load Database

Parses a saved backup file and fully reconstructs the in-memory database.


🚀 Getting Started

🔧 Compilation

gcc *.c -o inverted_search

▶️ Execution

./inverted_search file1.txt file2.txt file3.txt

🖥️ Sample Output

Enter word to search : embedded

✔ Word 'embedded' is present in 2 files
   📄 file1.txt  →  4 times
   📄 file3.txt  →  2 times

📚 Learning Outcomes

Working on this project provided hands-on experience with:

  • 🔢 Hash Table implementation from scratch
  • 🔗 Singly Linked Lists (Main & Sub node chaining)
  • 📁 File I/O and database persistence
  • 🧠 Dynamic memory allocation (malloc, free)
  • 🗃️ Data indexing and retrieval techniques
  • ⚡ Search optimization using hashing
  • 🧩 Modular programming in C

🔮 Future Enhancements

  • 🔡 Case-insensitive searching
  • 💬 Phrase / multi-word search
  • 🃏 Wildcard search support (*, ?)
  • 🖼️ GUI-based interface
  • 📦 Performance optimization for large datasets
  • 🌐 Web-based frontend for search queries

👨‍💻 Author

Avinash Patil

GitHub LinkedIn


Made with ❤️ and C

About

Data Structures project in C that performs file indexing and efficient keyword searching using hashing techniques.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.