@Override public float freqInNode() throws IOException { return scorer.freqInNode(); }
@Override public float freqInNode() throws IOException { return scorer.freqInNode(); }
@Override public float freqInNode() throws IOException { return reqScorer.freqInNode(); }
@Override public float freqInNode() throws IOException { return scorer.freqInNode(); }
/** * Compute the score and the frequency of the current document * @throws IOException */ private void computeScoreAndFreq() throws IOException { final int doc = this.docID(); if (doc != lastDoc) { lastDoc = doc; score = 0; freq = 0; do { // nextNode() was already called in nextDoc() or in advance() score += scorer.scoreInNode(); freq += scorer.freqInNode(); } while (scorer.nextNode()); } }
@Override public float freqInNode() throws IOException { // TODO: Computation similar to #scoreInNode. Could the instructions be // abstracted and merged somehow final float reqFreq = reqScorer.freqInNode(); final int doc = this.doc(); if (optScorer == null) { return reqFreq; } else if (optScorer.doc() < doc && // if it is the first call, optScorer.doc() returns -1 !optScorer.skipToCandidate(doc)) { optScorer = null; return reqFreq; } final IntsRef reqNode = this.node(); /* * the optional scorer can be in a node that is before the one where * the required scorer is in. */ int cmp = 1; while ((cmp = NodeUtils.compare(optScorer.node(), reqNode)) < 0) { if (!optScorer.nextNode()) { return reqFreq; } } // If the optional scorer matches the same node, increase the freq return (optScorer.doc() == doc && cmp == 0) ? reqFreq + optScorer.freqInNode() : reqFreq; }
@Override public Explanation explain(final AtomicReaderContext context, final int doc) throws IOException { final NodeScorer scorer = (NodeScorer) this.scorer(context, true, false, context.reader().getLiveDocs()); if (scorer != null) { if (scorer.skipToCandidate(doc) && scorer.doc() == doc) { final ExactSimScorer docScorer = similarity.exactSimScorer(stats, context); final ComplexExplanation result = new ComplexExplanation(); result.setDescription("weight("+this.getQuery()+" in "+doc+") [" + similarity.getClass().getSimpleName() + "], result of:"); while (scorer.nextNode()) { final ComplexExplanation nodeMatch = new ComplexExplanation(); nodeMatch.setDescription("in "+scorer.node()+"), result of:"); final float freq = scorer.freqInNode(); final Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "termFreq=" + freq)); nodeMatch.setValue(scoreExplanation.getValue()); nodeMatch.setMatch(true); nodeMatch.addDetail(scoreExplanation); result.addDetail(nodeMatch); } result.setMatch(true); return result; } } return new ComplexExplanation(false, 0.0f, "no matching term"); }
@Override public Explanation explain(final AtomicReaderContext context, final int doc) throws IOException { final NodeScorer scorer = (NodeScorer) this.scorer(context, true, false, context.reader().getLiveDocs()); if (scorer != null) { if (scorer.skipToCandidate(doc) && scorer.doc() == doc) { final SloppySimScorer docScorer = similarity.sloppySimScorer(stats, context); final ComplexExplanation result = new ComplexExplanation(); result.setDescription("weight("+this.getQuery()+" in "+doc+") [" + similarity.getClass().getSimpleName() + "], result of:"); while (scorer.nextNode()) { final ComplexExplanation nodeMatch = new ComplexExplanation(); nodeMatch.setDescription("in "+scorer.node()+"), result of:"); final float freq = scorer.freqInNode(); final Explanation scoreExplanation = docScorer.explain(doc, new Explanation(freq, "phraseFreq=" + freq)); nodeMatch.setValue(scoreExplanation.getValue()); nodeMatch.setMatch(true); nodeMatch.addDetail(scoreExplanation); result.addDetail(nodeMatch); } result.setMatch(true); return result; } } return new ComplexExplanation(false, 0.0f, "no matching term"); }
assertEquals(node(0,0), scorer.node()); final float d0score00 = scorer.scoreInNode(); final float d0freq00 = scorer.freqInNode(); assertFalse(scorer.nextNode()); assertEquals(DocsAndNodesIterator.NO_MORE_NOD, scorer.node()); assertEquals(node(0,1), scorer.node()); final float d1score01 = scorer.scoreInNode(); final float d1freq01 = scorer.freqInNode(); assertEquals(d0freq00, d1freq01, 0); assertFalse(scorer.nextNode()); final float d3freq11 = scorer.freqInNode(); assertTrue(d0freq00 > d3freq11); assertTrue(d1freq01 > d3freq11);