FileDocCategorySizeDatePackage
SpanScorer.javaAPI DocApache Lucene 2.2.03047Sat Jun 16 22:20:32 BST 2007org.apache.lucene.search.spans

SpanScorer

public class SpanScorer extends Scorer
Public for extension only.

Fields Summary
protected Spans
spans
protected Weight
weight
protected byte[]
norms
protected float
value
protected boolean
firstTime
protected boolean
more
protected int
doc
protected float
freq
Constructors Summary
protected SpanScorer(Spans spans, Weight weight, Similarity similarity, byte[] norms)


          
      
    super(similarity);
    this.spans = spans;
    this.norms = norms;
    this.weight = weight;
    this.value = weight.getValue();
    doc = -1;
  
Methods Summary
public intdoc()

 return doc; 
public org.apache.lucene.search.Explanationexplain(int doc)

    Explanation tfExplanation = new Explanation();

    skipTo(doc);

    float phraseFreq = (doc() == doc) ? freq : 0.0f;
    tfExplanation.setValue(getSimilarity().tf(phraseFreq));
    tfExplanation.setDescription("tf(phraseFreq=" + phraseFreq + ")");

    return tfExplanation;
  
public booleannext()

    if (firstTime) {
      more = spans.next();
      firstTime = false;
    }
    return setFreqCurrentDoc();
  
public floatscore()

    float raw = getSimilarity().tf(freq) * value; // raw score
    return raw * Similarity.decodeNorm(norms[doc]); // normalize
  
protected booleansetFreqCurrentDoc()

    if (! more) {
      return false;
    }
    doc = spans.doc();
    freq = 0.0f;
    while (more && doc == spans.doc()) {
      int matchLength = spans.end() - spans.start();
      freq += getSimilarity().sloppyFreq(matchLength);
      more = spans.next();
    }
    return more || (freq != 0);
  
public booleanskipTo(int target)

    if (firstTime) {
      more = spans.skipTo(target);
      firstTime = false;
    }
    if (! more) {
      return false;
    }
    if (spans.doc() < target) { // setFreqCurrentDoc() leaves spans.doc() ahead
      more = spans.skipTo(target);
    }
    return setFreqCurrentDoc();