/**
  * Check whether two Spans in the same document are ordered.
  *
  * @param spans1
  * @param spans2
  * @return true iff spans1 starts before spans2 or the spans start at the same position, and
  *     spans1 ends before spans2.
  */
 static final boolean docSpansOrdered(Spans spans1, Spans spans2) {
   assert spans1.doc() == spans2.doc() : "doc1 " + spans1.doc() + " != doc2 " + spans2.doc();
   int start1 = spans1.start();
   int start2 = spans2.start();
   /* Do not call docSpansOrdered(int,int,int,int) to avoid invoking .end() : */
   return (start1 == start2) ? (spans1.end() < spans2.end()) : (start1 < start2);
 }
 protected boolean setFreqCurrentDoc() throws IOException {
   if (!more) {
     return false;
   }
   doc = spans.doc();
   freq = 0.0f;
   do {
     int matchLength = spans.end() - spans.start();
     freq += similarity.sloppyFreq(matchLength);
     more = spans.next();
   } while (more && (doc == spans.doc()));
   return true;
 }
Exemple #3
0
  public boolean skipTo(int target) throws IOException {
    more = spans.skipTo(target);

    if (!more) return false;

    freq = 0.0f;
    doc = spans.doc();

    while (more && spans.doc() == target) {
      freq += getSimilarity().sloppyFreq(spans.end() - spans.start());
      more = spans.next();
    }

    return more || freq != 0.0f;
  }
Exemple #4
0
  public boolean next() throws IOException {
    if (firstTime) {
      more = spans.next();
      firstTime = false;
    }

    if (!more) return false;

    freq = 0.0f;
    doc = spans.doc();

    while (more && doc == spans.doc()) {
      int matchLength = spans.end() - spans.start();
      freq += getSimilarity().sloppyFreq(matchLength);
      more = spans.next();
    }

    return more || freq != 0.0f;
  }
 public String s(Spans span) {
   return s(span.doc(), span.start(), span.end());
 }
Exemple #6
0
 public int start() {
   return spans.start();
 }
 @Override
 public int start() {
   return spans.start();
 }