ntonellotto's picture
Update README.md
f55201c verified
|
Raw
History Blame Contribute Delete
1.44 kB
---
tags:
- pyterrier
- pyterrier-anserini
- pyterrier-artifact
task_categories:
- text-retrieval
viewer: false
language:
- en
pretty_name: Anserini index of the BRIGHT Sustainable Living collection for PyTerrier
---
# Anserini index of the BRIGHT Sustainable Living collection for PyTerrier
## Description
An Anserini index of the sustainable-living subset of the BRIGHT dataset build with PyTerrier's Anserini plugin.
## Usage
You will need to install PyTerrier, and its Anserini engine:
```python
%pip install pyjnius git+https://github.com/terrier-org/pyterrier.git
%pip install pyterrier-anserini
```
```python
import pyterrier as pt
anserini_index = pt.Artifact.from_hf("pyterrier-tutorial/bright.sustainable.anserini.text")
anserini_bm25 = anserini_index.bm25(k1=0.9, b=0.4)
anserinni_bm25.search("renewable energy and sustainable development").head(10)
```
## Reproduction
```python
from pyterrier_anserini import AnseriniIndex
anserini_path = "./bright-anserini-index"
if os.path.exists(anserini_path):
shutil.rmtree(anserini_path)
anserini_index = AnseriniIndex(anserini_path)
anserini_indexer = anserini_index.indexer(
fields=["text"],
store_positions=True,
verbose=True
)
dataset = pt.get_dataset('irds:bright/sustainable-living')
anserini_indexer.index(dataset.get_corpus_iter())
```
## Metadata
```
{
"type": "sparse_index",
"format": "anserini",
"package_hint": "pyterrier-anserini"
}
```