示例#1
0
        /// <summary>Reports the shrinked (without zero Frequency) Similars of the specified pattern.</summary>
        /// <param name="seedNumber">The number of the seed-word.</param>
        /// <returns>If Similars have zero-frequency items, the shrinked (without zero Frequency) Similars; otherwise initial Similars.</returns>
        public Similars GetSimilars(int seedNumber)
        {
            Similars smls        = Similars.GetSimilars(seedNumber);
            bool     isNotCopied = true;

            // We have to remove from the total Similars all the numbers with zero Frequency
            int  j;
            bool isFound = true;

            for (int i = 0; i < smls.Count; i++)
            {
                // scan throw the whole collection to check for real existing similars
                for (j = 0; j < Count; j++)
                {
                    if (isFound = this[j].SeedNumber == smls[i])
                    {
                        break;
                    }
                }
                if (!isFound)
                {
                    // if zero-frequence element is finded, Similars should be copied
                    // because it change its Count by shrinking
                    if (isNotCopied)
                    {
                        smls        = smls.Copy();
                        isNotCopied = false;
                    }
                    smls[i] = Similars.UndefNumber;
                }
            }
            return(isNotCopied ? smls : smls.Shrink());
        }
示例#2
0
        ///// <summary>Removes all the elements with the zero Frequency from the instance.</summary>
        ///// <remarks>Sorts the collection by Frequency.</remarks>
        //void Shrink ()
        //{
        //    if (_isShrinked == true)
        //        return;
        //    Sort();
        //    //System.Console.Beep(400, 100);
        //    // start from the end because zero Frequencies are much more less then unzero
        //    for (int i = Count-1; i >= 0; i--)
        //        //if (this[i].Freq > 0)
        //        if (this[i] > 0)
        //        {
        //            Array.Resize(ref _coll, _insCount = i+1);
        //            break;
        //        }
        //    _isShrinked = true;
        //}

        #endregion
        #region Statistic methods

        /// <summary>Reports the shrinked (without zero Frequency) Similars of the specified unsorted pattern.</summary>
        /// <param name="seedNumber">The number of the seed-word in the collection.</param>
        /// <returns>If Similars have zero-frequency items, the shrinked (without zero Frequency) Similars; otherwise initial Similars.</returns>
        public Similars GetSimilars(int seedNumber)
        {
            Similars smls        = Similars.GetSimilars(seedNumber);
            bool     isNotCopied = true;

            // We have to remove from the total Similars all the numbers with zero Frequency
            // this is a variant used in ScanWindows
            // we may use direct indexing to check zero-frequency seeds
            for (int i = 0; i < smls.Count; i++)
            {
                if (this[smls[i]] == 0)
                {
                    // if zero-frequence element is finded, Similars should be copied
                    // because it change its Count by shrinking
                    if (isNotCopied)
                    {
                        smls        = smls.Copy();
                        isNotCopied = false;
                    }
                    smls[i] = Similars.UndefNumber;
                }
            }
            return(isNotCopied ? smls : smls.Shrink());
        }