Giter VIP home page Giter VIP logo

aj_pdf_search_engine's Introduction

PDF Search Engine

This is a Python-based PDF search engine that allows you to search for relevant documents based on a query. The search engine utilizes the TF-IDF (Term Frequency-Inverse Document Frequency) algorithm to calculate the relevance scores between the query and the documents in a given directory.

Prerequisites

Make sure you have the following dependencies installed:

  • Python 3.x
  • PyPDF2
  • NLTK (Natural Language Toolkit)
  • scikit-learn (sklearn)
  • tqdm

You can install the required packages by running the following command:

pip install PyPDF2 nltk scikit-learn tqdm

Usage

1. Data Preparation

Place your PDF documents in a directory of your choice (e.g., "docs"). The search engine will extract text from the PDFs for indexing and searching.

2. Indexing

To build the TF-IDF index for the PDF documents, run the following command:

python pdf_search.py --docs <path_to_docs_directory> --index <index_filename.pkl> --update-index
  • <path_to_docs_directory>: Path to the directory containing the PDF documents.
  • <index_filename.pkl>: Name of the index file to be created or updated.
  • --update-index (optional): Use this flag to update the index if it already exists.

The indexing process may take some time, depending on the number and size of the PDF documents. The progress will be displayed with a progress bar.

3. Searching

Once the index is built, you can perform searches using the following command:

python pdf_search.py --index <index_filename.pkl>
  • <index_filename.pkl>: Path to the index file created during the indexing step. Enter your query when prompted. The search engine will display the top 5 most relevant documents based on your query.

To exit the search engine, simply enter 'q' when prompted for a query.

Additional Notes

  • The search engine preprocesses the documents by tokenizing the text, removing punctuation, converting text to lowercase, removing stopwords, and performing stemming using the Porter stemming algorithm.
  • The search engine uses cosine similarity to calculate the relevance scores between the query and the documents. The documents with the highest relevance scores are considered the most relevant.
  • The search engine saves the index data (TF-IDF matrix, vectorizer, document paths, and titles) as a pickle file for faster loading in subsequent runs. The index file can be updated by using the --update-index flag during the indexing step.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.