Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- #os.environ['JAVA_HOME'] = '/usr/lib/jvm/java-8-openjdk/'
- os.environ['JAVA_HOME'] = '/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre'
- import jnius_config
- #from jnius import JavaException
- jnius_config.set_classpath("target/anserini-0.4.1-SNAPSHOT-fatjar.jar")
- from jnius import autoclass
- #autoclass('org.jnius.NativeInvocationHandler')
- JString = autoclass('java.lang.String')
- JSearcher = autoclass('io.anserini.search.SimpleSearcher')
- searcher = JSearcher(JString('lucene-index.robust04.pos+docvectors+rawdocs'))
- hits = searcher.search(JString('hubble space telescope'))
- # the docid of the 1st hit
- hits[0].docid
- # the internal Lucene docid of the 1st hit
- hits[0].ldocid
- # the score of the 1st hit
- hits[0].score
- # the full document of the 1st hit
- hits[0].content
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement