예제 #1
0
        // next without initial increment
        private bool DoNext()
        {
            while (more)
            {
                while (more && first.doc < last.doc)
                {
                    // find doc w/ all the terms
                    more = first.SkipTo(last.doc); // skip first upto last
                    FirstToLast();                 // and move it to the end
                }

                if (more)
                {
                    // found a doc with all of the terms
                    freq = PhraseFreq(); // check for phrase
                    if (freq == 0.0f)
                    {
                        // no match
                        more = last.Next();
                    }
                    // trigger further scanning
                    else
                    {
                        return(true); // found a match
                    }
                }
            }
            return(false); // no more matches
        }
예제 #2
0
        //  private void printQueue(PrintStream ps, PhrasePositions ext, String title) {
        //    //if (min.doc != ?) return;
        //    ps.println();
        //    ps.println("---- "+title);
        //    ps.println("EXT: "+ext);
        //    PhrasePositions[] t = new PhrasePositions[pq.size()];
        //    if (pq.size()>0) {
        //      t[0] = pq.pop();
        //      ps.println("  " + 0 + "  " + t[0]);
        //      for (int i=1; i<t.length; i++) {
        //        t[i] = pq.pop();
        //        assert t[i-1].position <= t[i].position;
        //        ps.println("  " + i + "  " + t[i]);
        //      }
        //      // add them back
        //      for (int i=t.length-1; i>=0; i--) {
        //        pq.add(t[i]);
        //      }
        //    }
        //  }

        private bool AdvanceMin(int target)
        {
            if (!min.SkipTo(target))
            {
                max.doc = NO_MORE_DOCS; // for further calls to docID()
                return(false);
            }
            min = min.next; // cyclic
            max = max.next; // cyclic
            return(true);
        }
예제 #3
0
        //  private void printQueue(PrintStream ps, PhrasePositions ext, String title) {
        //    //if (min.doc != ?) return;
        //    ps.println();
        //    ps.println("---- "+title);
        //    ps.println("EXT: "+ext);
        //    PhrasePositions[] t = new PhrasePositions[pq.size()];
        //    if (pq.size()>0) {
        //      t[0] = pq.pop();
        //      ps.println("  " + 0 + "  " + t[0]);
        //      for (int i=1; i<t.length; i++) {
        //        t[i] = pq.pop();
        //        assert t[i-1].position <= t[i].position;
        //        ps.println("  " + i + "  " + t[i]);
        //      }
        //      // add them back
        //      for (int i=t.length-1; i>=0; i--) {
        //        pq.add(t[i]);
        //      }
        //    }
        //  }

        private bool AdvanceMin(int target)
        {
            if (!Min.SkipTo(target))
            {
                Max.Doc = NO_MORE_DOCS; // for further calls to docID()
                return(false);
            }
            Min = Min.next; // cyclic
            Max = Max.next; // cyclic
            return(true);
        }
예제 #4
0
 public override bool SkipTo(int target)
 {
     for (PhrasePositions pp = first; more && pp != null; pp = pp.next)
     {
         more = pp.SkipTo(target);
     }
     if (more)
     {
         Sort();                 // re-sort
     }
     return(DoNext());
 }
예제 #5
0
 public override int Advance(int target)
 {
     firstTime = false;
     for (PhrasePositions pp = first; more && pp != null; pp = pp.next)
     {
         more = pp.SkipTo(target);
     }
     if (more)
     {
         Sort(); // re-sort
     }
     if (!DoNext())
     {
         first.doc = NO_MORE_DOCS;
     }
     return(first.doc);
 }