Lucene评分函数 - 偏向于缩短文档

时间:2012-08-29 21:39:19

标签: java apache lucene tf-idf

我希望Lucene评分功能根据文档的长度没有偏差。这确实是Calculate the score only based on the documents have more occurance of term in lucene

的后续问题

我想知道Field.setOmitNorms(true)是如何工作的?我看到有两个因素可以让短文档获得高分:

  1. 使用doc.getBoost()
  2. “提升”较短的帖子 norm(t,d)定义中的
  3. “lengthNorm”
  4. Here is the documentation

    我在想 - 如果我不想偏向较短的文档,那么Field.setOmitNorms(true)就够了吗?

2 个答案:

答案 0 :(得分:1)

使用BM25Similarity可以减少到0f:

  

@param b控制文档长度标准化tf值的程度

  

@param k1控制非线性项频率归一化(饱和度)。

两个参数都会影响SimWeight

indexSearcher.setSimilarity(new BM25Similarity(1.2f,0f));

可在此处找到更多说明:http://opensourceconnections.com/blog/2015/10/16/bm25-the-next-generation-of-lucene-relevation/

答案 1 :(得分:0)

使用TF-IDF评分时,较短的文档更具相关性。

您可以在Lucene中使用自定义评分功能。它很容易定制评分算法。子类DefaultSimilarity并覆盖您要自定义的方法。

有一个代码示例here可以帮助您实现它

相关问题