示例#1
0
        public string GetSimilarTicketsSummary(string summary)
        {
            Init();
            Stopwatch timer;

            var ticket = new StringCompressible(summary);
            simObject.SetComplexity(ticket);

            timer = Stopwatch.StartNew();
            var results = simObject.FindSimilarValAndEntities(ticket, DataSet.ToArray());
            timer.Stop();

            var similarTickets = new List<Ticket>();
            foreach (var element in results)
            {
                similarTickets.Add(new Ticket {
                    oid = element.Item2.OID,
                    itemID = element.Item2.ItemID,
                    rating = element.Item1,
                    summary = element.Item2.Summary
                });
            }

            var jsonData = new
            {
                processTime = timer.ElapsedMilliseconds,
                similarTickets = similarTickets
            };
            return JsonConvert.SerializeObject(jsonData);
        }
示例#2
0
        /// <summary>
        /// Similar to FindSimilarEntites but returns a List of StringCompressibles
        /// rather than an array of ICompressibles and includes the NCD/MCD value in the return list
        /// </summary>
        /// <param name="entity">StringCompressible ticket to find similarities for</param>
        /// <param name="dataSet">Array of StringCompressible objects representing the ticket database</param>
        /// <returns>Returns an orderd list of similar entities.</returns>
        public List<Tuple<double, StringCompressible>> FindSimilarValAndEntities(StringCompressible entity, StringCompressible[] dataSet)
        {
            List<Tuple<double, StringCompressible>> similarEntities = new List<Tuple<double, StringCompressible>>();
            double similarityVal;

            foreach (StringCompressible entity2 in dataSet)
            {
                similarityVal = GetSimilarity(entity, entity2);
                if (similarityVal < threshold)
                {
                    similarEntities.Add(new Tuple<double, StringCompressible>(similarityVal, entity2));
                }
            }

            similarEntities.Sort((a, b) => a.Item1.CompareTo(b.Item1));

            return similarEntities;
        }
示例#3
0
        // Main function to run the acceptance tests
        static void Main(string[] args)
        {
            AcceptanceTests tester = new AcceptanceTests();

            // Create the golden set as an array of StringCompressible objects
            StringCompressible[] goldenSet = new StringCompressible[11] {
            new StringCompressible("IR-0026018", "Unable to start email connector after MR2 install"),
            new StringCompressible("IR-0026036", "When using SQL Scripts to Drop Incident Tables to wipe out test tickets - ON CG restart cg_IncidentRequest is not being recreated"),
            new StringCompressible("IR-0026137", "ChangeGear not starting"),
            new StringCompressible("IR-0026720", "When using SQL Scripts to Drop Incident Tables to wipe out test tickets - ON CG restart cg_IncidentRequest is not being recreated"),
            new StringCompressible("IR-0027472", "Email connector is not starting in dev envrionment"),
            new StringCompressible("IR-0027625", "Email connector service stopped  not restarting"),
            new StringCompressible("IR-0027693","Email connector service not starting"),
            new StringCompressible("IR-0027791", "Error when trying to save - Actual Start Date and End Date being used?"),
            new StringCompressible("IR-0028919", "We recently started using the SLA manager and now newly created after action rules are not being applied"),
            new StringCompressible("IR-0029185", "email connector service will not start after server reboot"),
            new StringCompressible("IR-0029334", "mail Connector Service does not start and has crashed the CGWeb Client")
            };

            // Counters
            int i = 0;
            int j = 0;

            // Check each of the 11 tickets against each other and print true if ncd value < threshhold, false otherwise
            foreach (StringCompressible element1 in goldenSet)
            {
                Console.Write("{0} matches: ", goldenSet[i].ItemID);
                foreach (StringCompressible element2 in goldenSet)
                {
                    if (tester.ContainsMatch(element1, element2, goldenSet) && i != j)
                    {
                        Console.Write("{0}, ", goldenSet[j].ItemID);
                    }
                    j++;
                }
                Console.WriteLine();
                j = 0;
                i++;
            }

            Console.Read(); // Prevents the console from closing
        }
示例#4
0
        /// <summary>
        /// Method to determine the MCD value between two tickets
        /// MCD(A,B) = max(|c(AB)-c(AA)|, |c(AB)-c(BB)|)/max(c(AA),c(BB))
        /// </summary>
        /// <param name="entity1">ICompressible ticket to operate MCD on</param>
        /// <param name="entity2">ICompressible ticket to operate MCD on</param>
        /// <returns>Double value representing the MCD value between the two tickets</returns>
        private double getMCD(ICompressible entity1, ICompressible entity2)
        {
            double MCD_numerator;
            double MCD_result;

            // Create two StringCompressible objects of the entities concatenated to themselves
            ICompressible AA = new StringCompressible (Encoding.ASCII.GetString(entity1.ToByteArray().Concat(entity1.ToByteArray()).ToArray()));
            ICompressible BB = new StringCompressible (Encoding.ASCII.GetString(entity2.ToByteArray().Concat(entity2.ToByteArray()).ToArray()));

            // Find c(AA) and c(BB)
            double MCD_AA = (double) GetComplexity(AA);
            double MCD_BB = (double) GetComplexity(BB);

            // Find c(AB)
            byte[] combinedArray = entity1.ToByteArray().Concat(entity2.ToByteArray()).ToArray();
            double MCD_AB = (double)compressionSize(combinedArray);

            // Find max( |c(AB)-c(AA)|, |c(AB)-c(BB)|)
            if (Math.Abs(MCD_AB - MCD_AA) >= Math.Abs(MCD_AB - MCD_BB))
            {
                MCD_numerator = Math.Abs(MCD_AB - MCD_AA);
            }
            else
            {
                MCD_numerator = Math.Abs(MCD_AB - MCD_BB);
            }

            // Find MCD(A,B)
            if (MCD_AA >= MCD_BB)
            {
                MCD_result = (MCD_numerator / MCD_AA);
            }
            else
            {
                MCD_result = (MCD_numerator / MCD_BB);
            }

            return MCD_result;
        }
示例#5
0
        private void setDataSet()
        {
            //Open the CSV to read in the data set
            var CSVReader = new StreamReader(System.IO.File.OpenRead(Path.Combine(Server.MapPath("~/App_Data"), "IncidentRequest.csv")));

            //Read in the "golden set" and add the entities to DataSet
            while (!CSVReader.EndOfStream)
            {
                var row = CSVReader.ReadLine().Split(',');
                var entity = new StringCompressible(row[0], row[2]);
                entity.ItemID = Regex.Replace(row[1], "IR-0+", "");
                simObject.SetComplexity(entity);
                DataSet.Add(entity);
            }
        }