@Test public void testRank() { System.out.println("rank"); int freq = 3; int docSize = 100; int avgDocSize = 150; int N = 10000000; int n = 1000; BM25 instance = new BM25(2.0, 0.75, 0.0); double expResult = 18.419481; double result = instance.score(freq, docSize, avgDocSize, N, n); assertEquals(expResult, result, 1E-6); }
@Override public double rank(Corpus corpus, TextTerms doc, String term, int tf, int n) { if (tf <= 0) return 0.0; int N = corpus.getNumDocuments(); int docSize = doc.size(); int avgDocSize = corpus.getAverageDocumentSize(); return score(tf, docSize, avgDocSize, N, n); }
BM25 implements RelevanceRanker { @Override public double rank(Corpus corpus, TextTerms doc, String term, int tf, int n) { if (tf <= 0) return 0.0; int N = corpus.getNumDocuments(); int docSize = doc.size(); int avgDocSize = corpus.getAverageDocumentSize(); return score(tf, docSize, avgDocSize, N, n); } }
BM25 implements RelevanceRanker { @Override public double rank(Corpus corpus, TextTerms doc, String term, int tf, int n) { if (tf <= 0) return 0.0; int N = corpus.getNumDocuments(); int docSize = doc.size(); int avgDocSize = corpus.getAverageDocumentSize(); return score(tf, docSize, avgDocSize, N, n); } BM25();  BM25(double k1, double b, double delta); }
BM25 implements RelevanceRanker { @Override public double rank(Corpus corpus, TextTerms doc, String term, int tf, int n) { if (tf <= 0) return 0.0; int N = corpus.getNumDocuments(); int docSize = doc.size(); int avgDocSize = corpus.getAverageDocumentSize(); return score(tf, docSize, avgDocSize, N, n); } BM25();  BM25(double k1, double b, double delta); double score(int termFreq, int docLen, double avgDocLen, int titleTermFreq, int titleLen, double avgTitleLen, int anchorTermFreq, int anchorLen, double avgAnchorLen, long N, long n); double score(double freq, long N, long n); double score(double freq, int docSize, double avgDocSize, long N, long n); @Override double rank(Corpus corpus, TextTerms doc, String term, int tf, int n); @Override double rank(Corpus corpus, TextTerms doc, String[] terms, int[] tf, int n); }
BM25 implements RelevanceRanker { @Override public double rank(Corpus corpus, TextTerms doc, String term, int tf, int n) { if (tf <= 0) return 0.0; int N = corpus.getNumDocuments(); int docSize = doc.size(); int avgDocSize = corpus.getAverageDocumentSize(); return score(tf, docSize, avgDocSize, N, n); } BM25();  BM25(double k1, double b, double delta); double score(int termFreq, int docLen, double avgDocLen, int titleTermFreq, int titleLen, double avgTitleLen, int anchorTermFreq, int anchorLen, double avgAnchorLen, long N, long n); double score(double freq, long N, long n); double score(double freq, int docSize, double avgDocSize, long N, long n); @Override double rank(Corpus corpus, TextTerms doc, String term, int tf, int n); @Override double rank(Corpus corpus, TextTerms doc, String[] terms, int[] tf, int n);  }