Example #1
0
        public override bool Next()
        {
            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);
        }
Example #2
0
            public virtual bool Next()
            {
                if (moreInclude)
                {
                    // move to next include
                    moreInclude = includeSpans.Next();
                }

                while (moreInclude && moreExclude)
                {
                    if (includeSpans.Doc() > excludeSpans.Doc())
                    {
                        // skip exclude
                        moreExclude = excludeSpans.SkipTo(includeSpans.Doc());
                    }

                    while (moreExclude && includeSpans.Doc() == excludeSpans.Doc() && excludeSpans.End() <= includeSpans.Start())
                    {
                        moreExclude = excludeSpans.Next();                         // increment exclude
                    }

                    if (!moreExclude || includeSpans.Doc() != excludeSpans.Doc() || includeSpans.End() <= excludeSpans.Start())
                    {
                        break;                         // we found a match
                    }
                    moreInclude = includeSpans.Next(); // intersected: keep scanning
                }
                return(moreInclude);
            }
Example #3
0
 public override int Advance(int target)
 {
     if (!more)
     {
         return(doc = NO_MORE_DOCS);
     }
     if (spans.Doc() < target)
     {
         // setFreqCurrentDoc() leaves spans.doc() ahead
         more = spans.SkipTo(target);
     }
     if (!SetFreqCurrentDoc())
     {
         doc = NO_MORE_DOCS;
     }
     return(doc);
 }
Example #4
0
            public override bool LessThan(System.Object o1, System.Object o2)
            {
                Spans spans1 = (Spans)o1;
                Spans spans2 = (Spans)o2;

                if (spans1.Doc() == spans2.Doc())
                {
                    if (spans1.Start() == spans2.Start())
                    {
                        return(spans1.End() < spans2.End());
                    }
                    else
                    {
                        return(spans1.Start() < spans2.Start());
                    }
                }
                else
                {
                    return(spans1.Doc() < spans2.Doc());
                }
            }
Example #5
0
 //
 protected internal override bool SetFreqCurrentDoc()
 {
     if (!More)
     {
         return(false);
     }
     Doc          = Spans.Doc();
     Freq_Renamed = 0.0f;
     PayloadScore = 0;
     PayloadsSeen = 0;
     do
     {
         int matchLength = Spans.End() - Spans.Start();
         Freq_Renamed += DocScorer.ComputeSlopFactor(matchLength);
         Spans[] spansArr = new Spans[1];
         spansArr[0] = Spans;
         GetPayloads(spansArr);
         More = Spans.Next();
     } while (More && (Doc == Spans.Doc()));
     return(true);
 }
Example #6
0
                protected internal override bool SetFreqCurrentDoc()
                {
                    if (!More)
                    {
                        return(false);
                    }
                    Doc                  = Spans.Doc();
                    Freq_Renamed         = 0.0f;
                    NumMatches           = 0;
                    PayloadScore_Renamed = 0;
                    PayloadsSeen         = 0;
                    while (More && Doc == Spans.Doc())
                    {
                        int matchLength = Spans.End() - Spans.Start();

                        Freq_Renamed += DocScorer.ComputeSlopFactor(matchLength);
                        NumMatches++;
                        ProcessPayload(OuterInstance.Similarity);

                        More = Spans.Next(); // this moves positions to the next match in this
                        // document
                    }
                    return(More || (Freq_Renamed != 0));
                }
Example #7
0
 public virtual int Doc()
 {
     return(spans.Doc());
 }