https://leetexplorer.onrender.com/
- Clone the repository
- Run the prepare.py file to create the inverted index and the document frequency file
- Run the app.py (flask --app app run) file to get the results for the queries
This project is a LeetCode question search tool that utilizes TF-IDF (Term Frequency-Inverse Document Frequency) and an inverted index to search for relevant questions based on keywords or tags. The search results are presented through a user-friendly web interface.
The project consists of three main components:
-
Data Preprocessing (
prepare.py
): The script processes the LeetCode question data, creating a vocabulary, calculating IDF values, and building an inverted index. -
Web Application (
app.py
andindex.html
): The Flask-based web application offers a user interface for conducting searches. It employs the processed data to calculate and display relevant question links.
To use the LeetCode Question Search Tool, follow these steps:
-
Data Preprocessing:
- Ensure you have the LeetCode question data saved in the
Qdata
folder. - Run
prepare.py
to preprocess the data, generate the vocabulary, IDF values, documents, and inverted index. - Processed data files are stored in the
tf-idf
folder.
- Ensure you have the LeetCode question data saved in the
-
Web Application:
- Install the required Python packages by running
pip install flask flask_wtf
. - Run
app.py
to launch the Flask web application. - Access the application by navigating to
http://127.0.0.1:5000
in your web browser.
- Install the required Python packages by running
- Open the web application in your browser.
- Input keywords or tags into the search box and click the "Search" button.
- The application will display relevant question links, sorted by relevance score.
- Python 3.x
- Flask
- Flask-WTF
-
prepare.py
: Data preprocessing script -
app.py
: Flask web application script -
index.html
: HTML template for the web interface -
tf-idf
: Processed data foldervocab.txt
: Vocabulary of terms and their IDF valuesidf-values.txt
: IDF values for each termdocuments.txt
: Processed documentsinverted-index.txt
: Inverted index mapping terms to document indexes
Feel free to contribute by submitting issues or pull requests. Your feedback and contributions are highly appreciated.
This project is licensed under the MIT License.