/// <summary> /// By default, uses the <seealso cref="PayloadFunction"/> to score the payloads, but /// can be overridden to do other things. /// </summary> /// <param name="payLoads"> The payloads </param> /// <param name="start"> The start position of the span being scored </param> /// <param name="end"> The end position of the span being scored /// </param> /// <seealso cref= Spans </seealso> protected internal virtual void ProcessPayloads(ICollection <byte[]> payLoads, int start, int end) { foreach (var thePayload in payLoads) { Scratch.Bytes = thePayload; Scratch.Offset = 0; Scratch.Length = thePayload.Length; PayloadScore = OuterInstance.Function.CurrentScore(Doc, OuterInstance.FieldName, start, end, PayloadsSeen, PayloadScore, DocScorer.ComputePayloadFactor(Doc, Spans.Start(), Spans.End(), Scratch)); ++PayloadsSeen; } }
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()); } }
public /*protected internal*/ virtual bool SetFreqCurrentDoc() { 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); }
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)); }
protected internal virtual void ProcessPayload(Similarity similarity) { if (TermSpans.PayloadAvailable) { DocsAndPositionsEnum postings = TermSpans.Postings; Payload = postings.Payload; if (Payload != null) { PayloadScore_Renamed = OuterInstance.OuterInstance.Function.CurrentScore(Doc, OuterInstance.OuterInstance.Term.Field, Spans.Start(), Spans.End(), PayloadsSeen, PayloadScore_Renamed, DocScorer.ComputePayloadFactor(Doc, Spans.Start(), Spans.End(), Payload)); } else { PayloadScore_Renamed = OuterInstance.OuterInstance.Function.CurrentScore(Doc, OuterInstance.OuterInstance.Term.Field, Spans.Start(), Spans.End(), PayloadsSeen, PayloadScore_Renamed, 1F); } PayloadsSeen++; } else { // zero out the payload? } }
public virtual int Start() { return(spans.Start()); }
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); }