SHARE
TWEET

Untitled

a guest May 22nd, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import os
  2. #os.environ['JAVA_HOME'] = '/usr/lib/jvm/java-8-openjdk/'
  3. os.environ['JAVA_HOME'] = '/Library/Java/JavaVirtualMachines/adoptopenjdk-8.jdk/Contents/Home/jre'
  4.  
  5.  
  6. import jnius_config
  7. #from jnius import JavaException
  8. jnius_config.set_classpath("target/anserini-0.4.1-SNAPSHOT-fatjar.jar")
  9.  
  10. from jnius import autoclass
  11. #autoclass('org.jnius.NativeInvocationHandler')
  12. JString = autoclass('java.lang.String')
  13. JSearcher = autoclass('io.anserini.search.SimpleSearcher')
  14.  
  15. searcher = JSearcher(JString('lucene-index.robust04.pos+docvectors+rawdocs'))
  16. hits = searcher.search(JString('hubble space telescope'))
  17.  
  18. # the docid of the 1st hit
  19. hits[0].docid
  20.  
  21. # the internal Lucene docid of the 1st hit
  22. hits[0].ldocid
  23.  
  24. # the score of the 1st hit
  25. hits[0].score
  26.  
  27. # the full document of the 1st hit
  28. hits[0].content
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top