Provides various BM25 algorithms (BM25Okapi, BM25L, BM25Plus) for document ranking based on a corpus of tokenized documents. It's currently at version 0.2.2 and appears to have an infrequent release cadence, with the latest update adding support for non-iterable corpuses.
pip install rank-bm25Verified import paths — ran on the pinned version, not inferred.
This example demonstrates how to initialize BM25Okapi with a tokenized corpus and then retrieve scores and top-N documents for a given tokenized query.
Ensure your corpus (list of documents) and queries are tokenized into lists of words (e.g., using `doc.split(' ')` or an NLP tokenizer) before passing them to the BM25 constructor or `get_scores`/`get_top_n` methods.Use `pip install rank-bm25` for installation and `from rank_bm25 import ...` for importing classes like `BM25Okapi`.
For versions prior to 0.2.2, ensure your corpus is a concrete list of tokenized documents. For 0.2.2+, generators are supported, but remember they are single-pass and may need to be re-initialized if reused.
No dependency data recorded yet.