据我所知,pyLucene现在也提供了BM25相似度。我正在使用pyLucene - 4.10.1,但是找不到任何关于如何使用BM25而不是tf-idf的示例。请指点一下。
发布于 2018-03-22 23:17:38
尝试使用IndexSearcher的setSimilarity设置检索模型。
import lucene
from java.nio.file import Paths
from org.apache.lucene.store import SimpleFSDirectory
from org.apache.lucene.index import DirectoryReader
from org.apache.lucene.search import IndexSearcher
from org.apache.lucene.search.similarities import BM25Similarity
lucene.initVM(vmargs=['-Djava.awt.headless=true'])
directory = SimpleFSDirectory(Paths.get(INDEX_DIR))
searcher = IndexSearcher(DirectoryReader.open(directory))
searcher.setSimilarity(BM25Similarity())https://stackoverflow.com/questions/43831880
复制相似问题