Python Search Engine
O Python Search Engine é um motor de busca construído do zero em Python com armazenamento local via interface de linha de comando (CLI). Ele utiliza um índice invertido e o algoritmo de ranqueamento BM25 para buscar e recuperar documentos de texto (.txt) de forma eficiente.
The Python Search Engine is a search engine built from scratch in Python with local CLI storage. It uses an inverted index and the BM25 ranking algorithm to efficiently search and retrieve text documents (.txt).
Como funcionaHow it works
A ferramenta opera inteiramente no terminal. Ao inicializar, ela cria uma estrutura de armazenamento persistente local (.search_data/). Você pode adicionar arquivos de texto, diretórios inteiros ou até mesmo texto bruto. O sistema processa o texto, remove stopwords e constrói um índice invertido binário (usando pickle). Durante a busca, o algoritmo BM25 calcula a relevância de cada documento em relação à consulta, retornando os resultados mais precisos.
The tool operates entirely in the terminal. Upon initialization, it creates a local persistent storage structure (.search_data/). You can add text files, entire directories, or even raw text. The system processes the text, removes stopwords, and builds a binary inverted index (using pickle). During a search, the BM25 algorithm calculates the relevance of each document to the query, returning the most accurate results.
Exemplo de UsoUsage Example
A interação é feita através do script search_cli.py. Primeiro, você inicializa o armazenamento e adiciona seus documentos:
Interaction is done through the search_cli.py script. First, you initialize the storage and add your documents:
$ python search_cli.py init $ python search_cli.py add --dir ./meus_documentos
Depois, basta realizar uma busca especificando a consulta e a quantidade de resultados (Top-K) desejados: Then, simply perform a search by specifying the query and the number of desired results (Top-K):
$ python search_cli.py search --query "python inverted index" --top-k 5
MotivaçãoMotivation
Este projeto foi desenvolvido para estudar os fundamentos de Recuperação de Informação (Information Retrieval). Construir um motor de busca do zero foi a melhor forma de entender na prática como funcionam a tokenização, a criação de índices invertidos e a matemática por trás de algoritmos de ranqueamento clássicos como o BM25. This project was developed to study the fundamentals of Information Retrieval. Building a search engine from scratch was the best way to practically understand tokenization, the creation of inverted indexes, and the math behind classic ranking algorithms like BM25.