This project includes two main Python scripts: create_index.py
and search.py
. These scripts handle building and querying an index to support efficient data retrieval from a specified dataset.
- Description: This script is responsible for building an index by processing the input dataset and storing it in an index file for efficient querying.
- Main Functions:
- Loads data from a specified file path.
- Builds an efficient index structure for rapid searching.
- Saves the generated index to disk for later retrieval.
- Usage:
- Ensure the data file path is correctly set.
- Run the script from the command line:
python create_index.py --data_path path/to/data --index_path path/to/save/index
- Parameters:
--data_path
: Path to the data file.--index_path
: Path to save the generated index.
- Description: This script allows for querying an existing index to return results that match the user's search query.
- Main Functions:
- Loads a pre-built index.
- Takes a user search query as input.
- Searches the index for matching results and ranks them by relevance.
- Outputs or saves the search results.
- Usage:
- Ensure the index file has been created.
- Run the script from the command line:
python search.py --index_path path/to/index --query "your search query"
- Parameters:
--index_path
: Path to the index file.--query
: Search query.
- Python Version: Requires Python 3.7 or higher.
- Dependencies:
- List any necessary libraries here, such as
numpy
,scipy
, etc.
- List any necessary libraries here, such as
Install the required Python packages by running:
pip install -r requirements.txt
- Run
create_index.py
to generate the index. - Run
search.py
to perform a search.
python create_index.py --data_path data/sample_data.txt --index_path index/sample_index.idx
python search.py --index_path index/sample_index.idx --query "example search term"
This project is licensed under the MIT License.