Lucene 5.3中的术语频率评分 [英] Term frequency scoring in lucene 5.3

查看:96
本文介绍了Lucene 5.3中的术语频率评分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只想使用术语频率来对Apache Lucene 5.3中的结果进行排名.我尝试覆盖DefaultSimilarity类,但似乎在Lucene 5.3中不起作用.我正在使用以下代码:

I want to use only the term frequency to rank the results in Apache Lucene 5.3. I tried overriding the DefaultSimilarity class, but it seems it is not working in Lucene 5.3. I am using the following code:

import org.apache.lucene.search.similarities.DefaultSimilarity;

public class TfSimilarity extends DefaultSimilarity {
    public TfSimilarity(){}
    public float idf(int docFreq, int numDocs) {
      return(float)1.0;
    }
    public float coord(int overlap, int maxOverlap) {
      return 1.0f;
    }
    public float lengthNorm(String fieldName, int numTerms) {
      return (float) numTerms;
    }

}

此外,该程序似乎不在上面的idf函数中.

Moreover, it seems that the program is not going inside the idf function above.

推荐答案

您没有覆盖您应该使用带注释的@Override来确保正确地定义了方法定义.

You should use the @Override annotated to make sure you've got the method definition correctly.

这篇关于Lucene 5.3中的术语频率评分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆