Esempio n. 1
0
        public void setup()
        {
            string path = @"D:\CPSC\CPSC571\571CourseProject\";
            string fn = "data/abracadabra.data";
            s = "abcabcabcabcdefghiihgabcabababab$";

            st = new SuffTree(s, minTh, tolWin, dmax, minLengthSegment,
                path + fn + "-Th=" + minTh + ", TolWin=" + tolWin, -2);
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            /*
             * SuffixArray sa = new SuffixArray("abracadabra");
             * Console.WriteLine(sa.FindSubstring("ac"));
             * var allSubstrings = sa.FindAllSubstrings("a");
             * foreach (var index in allSubstrings)
             * {
             *  Console.WriteLine("index of occurence of a: " + index);
             * }
             */
            ///////////////////////////////////////////////////////////////////////
            /////////// This is the complexity improved version working \\\\\\\\\\\
            //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

            //int[] occur = new int[]{0,3,5,6,9,13,15,18,19,21};
            //CalculatePeriod(occur, s.Length);

            //String fn = @"c:\output";

            string path = @"D:\CPSC\CPSC571\571CourseProject\";

            periodCollection = new List <CPeriod>();
            preCountPerCol   = periodCollection.Count;
            candPerCount     = 0; addPerCount = 0; occVecCount = 0;
            string       fn = "data/abracadabra.data";
            FileStream   fs = new FileStream(path + fn, FileMode.Open);
            StreamReader sr = new StreamReader(fs);

            s = sr.ReadToEnd().Trim() + "$";

            Console.WriteLine(s);
            Console.WriteLine("01234567890123456789");
            Console.WriteLine();

            SuffTree st = new SuffTree(s, minTh, tolWin, dmax, minLengthSegment,
                                       path + fn + "-Th=" + minTh + ", TolWin=" + tolWin, -2);

            Console.WriteLine("Candidate Period Count: " + candPerCount);
            Console.WriteLine("Added Period Count: " + addPerCount);
            Console.WriteLine("Occur Vector Count: " + occVecCount);
            Console.WriteLine();


            /* int y = 0;
             * for (int i = 0; i < periodCollection.Count; i++)
             * {
             * if (((periodCollection[i].lastOccur + periodCollection[i].strlen - periodCollection[i].st) % periodCollection[i].p) >= periodCollection[i].strlen) y = 1; else y = 0;
             * periodCollection[i].th = periodCollection[i].count / Math.Floor(((double)(periodCollection[i].lastOccur + periodCollection[i].strlen - periodCollection[i].st) / periodCollection[i].p) + y);
             *
             * Console.WriteLine();
             * Console.WriteLine("String: " + s.Substring(periodCollection[i].st, periodCollection[i].strlen));
             * Console.WriteLine("Period: " + periodCollection[i].p);
             * Console.WriteLine("St: " + periodCollection[i].st);
             * Console.WriteLine("End: " + periodCollection[i].lastOccur);
             * Console.WriteLine("Count: " + periodCollection[i].count);
             * Console.WriteLine("Conf: " + periodCollection[i].th);
             * }
             * Console.WriteLine("\r\nTotal Periods: " + periodCollection.Count);
             */
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            /*
            SuffixArray sa = new SuffixArray("abracadabra");
            Console.WriteLine(sa.FindSubstring("ac"));
            var allSubstrings = sa.FindAllSubstrings("a");
            foreach (var index in allSubstrings)
            {
                Console.WriteLine("index of occurence of a: " + index);
            }
            */
            ///////////////////////////////////////////////////////////////////////
            /////////// This is the complexity improved version working \\\\\\\\\\\
            //\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

            //int[] occur = new int[]{0,3,5,6,9,13,15,18,19,21};
            //CalculatePeriod(occur, s.Length);

            //String fn = @"c:\output";

            string path = @"D:\CPSC\CPSC571\571CourseProject\";

            periodCollection = new List<CPeriod>();
            preCountPerCol = periodCollection.Count;
            candPerCount = 0; addPerCount = 0; occVecCount = 0;
            string fn = "data/abracadabra.data";
            FileStream fs = new FileStream(path + fn, FileMode.Open);
            StreamReader sr = new StreamReader(fs);
            s = sr.ReadToEnd().Trim() + "$";

            Console.WriteLine(s);
            Console.WriteLine("01234567890123456789");
            Console.WriteLine();

            SuffTree st = new SuffTree(s, minTh, tolWin, dmax, minLengthSegment,
                path + fn + "-Th=" + minTh + ", TolWin=" + tolWin, -2);

            Console.WriteLine("Candidate Period Count: " + candPerCount);
            Console.WriteLine("Added Period Count: " + addPerCount);
            Console.WriteLine("Occur Vector Count: " + occVecCount);
            Console.WriteLine();

            /* int y = 0;
               for (int i = 0; i < periodCollection.Count; i++)
               {
               if (((periodCollection[i].lastOccur + periodCollection[i].strlen - periodCollection[i].st) % periodCollection[i].p) >= periodCollection[i].strlen) y = 1; else y = 0;
               periodCollection[i].th = periodCollection[i].count / Math.Floor(((double)(periodCollection[i].lastOccur + periodCollection[i].strlen - periodCollection[i].st) / periodCollection[i].p) + y);

               Console.WriteLine();
               Console.WriteLine("String: " + s.Substring(periodCollection[i].st, periodCollection[i].strlen));
               Console.WriteLine("Period: " + periodCollection[i].p);
               Console.WriteLine("St: " + periodCollection[i].st);
               Console.WriteLine("End: " + periodCollection[i].lastOccur);
               Console.WriteLine("Count: " + periodCollection[i].count);
               Console.WriteLine("Conf: " + periodCollection[i].th);
               }
               Console.WriteLine("\r\nTotal Periods: " + periodCollection.Count);
               */
        }