Skip to content

Latest commit

 

History

History
21 lines (15 loc) · 771 Bytes

usage-pyjnius.md

File metadata and controls

21 lines (15 loc) · 771 Bytes

Pyserini: Direct Interaction via Pyjnius

For parts of Anserini that have not yet been integrated into the Pyserini interface, you can interact with Anserini's Java classes directly via pyjnius. First, call Pyserini's setup helper for setting up classpath for the JVM:

from pyserini.setup import configure_classpath
configure_classpath('pyserini/resources/jars')

Now autoclass can be used to provide direct access to Java classes:

from jnius import autoclass

JIndexReaderUtils = autoclass('io.anserini.index.IndexReaderUtils')
reader = JIndexReaderUtils.getReader('indexes/index-robust04-20191213/')

# Fetch raw document contents by id:
rawdoc = JIndexReaderUtils.documentRaw(reader, 'FT934-5418')