コード例 #1
0
ファイル: PhraseScorer.cs プロジェクト: yonder/mono
 protected internal void  FirstToLast()
 {
     last.next = first;             // move first to end of list
     last      = first;
     first     = first.next;
     last.next = null;
 }
コード例 #2
0
        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);
        }
コード例 #3
0
ファイル: PhraseScorer.cs プロジェクト: yonder/mono
 private void  Sort()
 {
     pq.Clear();
     for (PhrasePositions pp = first; pp != null; pp = pp.next)
     {
         pq.Put(pp);
     }
     PqToList();
 }
コード例 #4
0
ファイル: PhraseScorer.cs プロジェクト: yonder/mono
 private void  Init()
 {
     for (PhrasePositions pp = first; more && pp != null; pp = pp.next)
     {
         more = pp.Next();
     }
     if (more)
     {
         Sort();
     }
 }
コード例 #5
0
ファイル: PhraseScorer.cs プロジェクト: yonder/mono
 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());
 }
コード例 #6
0
ファイル: PhraseQueue.cs プロジェクト: raj581/Marvin
        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);
            }
        }
コード例 #7
0
ファイル: SloppyPhraseScorer.cs プロジェクト: raj581/Marvin
        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);
        }
コード例 #8
0
ファイル: PhraseScorer.cs プロジェクト: yonder/mono
 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;
     }
 }
コード例 #9
0
		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
		}
コード例 #10
0
ファイル: PhraseScorer.cs プロジェクト: yonder/mono
        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
        }
コード例 #11
0
		protected internal void  FirstToLast()
		{
			last.next = first; // move first to end of list
			last = first;
			first = first.next;
			last.next = null;
		}
コード例 #12
0
		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;
			}
		}