protected internal void FirstToLast() { last.next = first; // move first to end of list last = first; first = first.next; last.next = null; }
protected internal override float PhraseFreq() { // sort list with pq for (PhrasePositions pp = first; pp != null; pp = pp.next) { pp.FirstPosition(); pq.Put(pp); // build pq from list } PqToList(); // rebuild list from pq int freq = 0; do { // find position w/ all terms while (first.position < last.position) { // scan forward in first do { if (!first.NextPosition()) { return((float)freq); } }while (first.position < last.position); FirstToLast(); } freq++; // all equal: a match }while (last.NextPosition()); return((float)freq); }
private void Sort() { pq.Clear(); for (PhrasePositions pp = first; pp != null; pp = pp.next) { pq.Put(pp); } PqToList(); }
private void Init() { for (PhrasePositions pp = first; more && pp != null; pp = pp.next) { more = pp.Next(); } if (more) { Sort(); } }
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()); }
public override bool LessThan(System.Object o1, System.Object o2) { PhrasePositions pp1 = (PhrasePositions)o1; PhrasePositions pp2 = (PhrasePositions)o2; if (pp1.doc == pp2.doc) { return(pp1.position < pp2.position); } else { return(pp1.doc < pp2.doc); } }
protected internal override float PhraseFreq() { pq.Clear(); int end = 0; for (PhrasePositions pp = first; pp != null; pp = pp.next) { pp.FirstPosition(); if (pp.position > end) { end = pp.position; } pq.Put(pp); // build pq from list } float freq = 0.0f; bool done = false; do { PhrasePositions pp = (PhrasePositions)pq.Pop(); int start = pp.position; int next = ((PhrasePositions)pq.Top()).position; for (int pos = start; pos <= next; pos = pp.position) { start = pos; // advance pp to min window if (!pp.NextPosition()) { done = true; // ran out of a term -- done break; } } int matchLength = end - start; if (matchLength <= slop) { freq += GetSimilarity().SloppyFreq(matchLength); // score match } if (pp.position > end) { end = pp.position; } pq.Put(pp); // restore pq }while (!done); return(freq); }
protected internal void PqToList() { last = first = null; while (pq.Top() != null) { PhrasePositions pp = (PhrasePositions)pq.Pop(); if (last != null) { // add next to end of list last.next = pp; } else { first = pp; } last = pp; pp.next = null; } }
internal PhraseScorer(Weight weight, TermPositions[] tps, int[] positions, Similarity similarity, byte[] norms) : base(similarity) { this.norms = norms; this.weight = weight; this.value_Renamed = weight.Value; // convert tps to a list for (int i = 0; i < tps.Length; i++) { PhrasePositions pp = new PhrasePositions(tps[i], positions[i]); if (last != null) { // add next to end of list last.next = pp; } else first = pp; last = pp; } pq = new PhraseQueue(tps.Length); // construct empty pq }
internal PhraseScorer(Weight weight, TermPositions[] tps, int[] positions, Similarity similarity, byte[] norms) : base(similarity) { this.norms = norms; this.weight = weight; this.value_Renamed = weight.Value; // convert tps to a list for (int i = 0; i < tps.Length; i++) { PhrasePositions pp = new PhrasePositions(tps[i], positions[i]); if (last != null) { // add next to end of list last.next = pp; } else { first = pp; } last = pp; } pq = new PhraseQueue(tps.Length); // construct empty pq }
protected internal void PqToList() { last = first = null; while (pq.Top() != null) { PhrasePositions pp = (PhrasePositions) pq.Pop(); if (last != null) { // add next to end of list last.next = pp; } else first = pp; last = pp; pp.next = null; } }