Example #1
0
 public void Trim(int size)
 {
     Object[] elements = this.sorted.ToArray();
     for (int i = 0; i < elements.Length; i++)
     {
         if (i >= size)
         {
             HistogramElement element = (HistogramElement)elements[i];
             this.histogram.Remove(element.Word);
             this.sorted.Remove(element);
         }
     }
 }
Example #2
0
 public void RemoveCommon(WordHistogram other)
 {
     foreach (HistogramElement element in other.Sorted)
     {
         HistogramElement e = this.Get(element.Word);
         if (e == null)
         {
             continue;
         }
         this.sorted.Remove(e);
         this.histogram.Remove(element.Word);
     }
 }
Example #3
0
 public void RemoveBelow(int value)
 {
     Object[] elements = this.sorted.ToArray();
     for (int i = 0; i < elements.Length; i++)
     {
         HistogramElement element = (HistogramElement)elements[i];
         if (element.Count < value)
         {
             this.histogram.Remove(element.Word);
             this.sorted.Remove(element);
         }
     }
 }
        public int CompareTo(object obj)
        {
            HistogramElement o = (HistogramElement)obj;
            int result         = o.Count - this.Count;

            if (result == 0)
            {
                return(this.Word.CompareTo(o.Word));
            }
            else
            {
                return(result);
            }
        }
Example #5
0
        public void RemovePercent(double percent)
        {
            int countdown = (int)(this.sorted.Count * (1 - percent));

            Object[] elements = this.sorted.ToArray();
            for (int i = 0; i < elements.Length; i++)
            {
                countdown--;
                if (countdown < 0)
                {
                    HistogramElement element = (HistogramElement)elements[i];
                    this.histogram.Remove(element.Word);
                    this.sorted.Remove(element);
                }
            }
        }
Example #6
0
 public void BuildFromWord(String word)
 {
     word = word.Trim().ToLower();
     if (this.common.IsCommonWord(word))
     {
         if (this.histogram.ContainsKey(word))
         {
             HistogramElement element = this.histogram[word];
             element.Increase();
         }
         else
         {
             HistogramElement element = new HistogramElement(word, 1);
             this.histogram[word] = element;
         }
     }
 }
Example #7
0
        public void BuildFromWord(String word)
        {
            word = word.Trim().ToLower();
            if (this.common.IsCommonWord(word))
            {
                if (this.histogram.ContainsKey(word))
                {
                    HistogramElement element = this.histogram[word]; 
                    element.Increase();
                }
                else
                {
                    HistogramElement element = new HistogramElement(word, 1);
                    this.histogram[word] = element;
                }

            }
        }