예제 #1
0
        public static void RunTest()
        {
            while (true)
            {
                Console.Write("string A:");
                string strA = Console.ReadLine().Trim();
                if (strA.Equals("q", StringComparison.OrdinalIgnoreCase))
                {
                    break;
                }
                Console.Write("string B:");
                string strB = Console.ReadLine().Trim();
                if (strB.Equals("q", StringComparison.OrdinalIgnoreCase))
                {
                    break;
                }
                int times = 1;

                double similar = 0;
                var    dt1     = DateTime.Now;
                for (int i = 0; i < times; i++)
                {
                    similar = Similar.SimilarityBy_LD_LCS(strA, strB);
                }
                var dt2 = DateTime.Now;

                Console.WriteLine("similar:{2}-{3},The similar is:{0},time:{1}", similar, (dt2 - dt1).TotalMilliseconds, strA.Length, strB.Length);

                Console.WriteLine();
            }
        }
        public static double SimilarImage(Image aImage, Image bImage)
        {
            string sa = ReadPix(aImage);
            string sb = ReadPix(bImage);

            Console.WriteLine(sa.Length);
            Console.WriteLine(sb.Length);
            return(Similar.SimilarityBy_LD_LCS(sa, sb));
        }
예제 #3
0
        public static void WWWCompareFiles()
        {
            List <string> list       = new List <string>();
            string        siteFormat = @"E:\Code\WWWreview\current\QuidsiWebSite\{0}\Views\Marco\IntegerTextBox.svm";

            Sites.ForEach(s =>
            {
                list.Add(string.Format(siteFormat, s));
            });

            var results = Similar.FileSimilar(list);

            results.ForEach(Console.WriteLine);
        }
예제 #4
0
        public static List <string> FileSimilar(List <string> filePaths)
        {
            if (filePaths == null || filePaths.Count == 0)
            {
                return(new List <string>());
            }
            string baseFile = filePaths.Find(File.Exists);

            if (baseFile == null)
            {
                return new List <string>()
                       {
                           "all files don't exist"
                       }
            }
            ;

            List <string> listMsg = new List <string>(filePaths.Count);

            listMsg.Add(string.Format("{0},\t{1}", new FileInfo(baseFile).Name, 1));

            string baseContent = File.ReadAllText(baseFile);

            foreach (string f in filePaths)
            {
                if (f == baseFile)
                {
                    continue;
                }

                if (File.Exists(f) == false)
                {
                    listMsg.Add(string.Format("{0},\t{1}", new FileInfo(baseFile).Name, "not exist"));
                    continue;
                }

                double d = Similar.SimilarityBy_LD_LCSIgonorSpace(baseContent, File.ReadAllText(f));

                listMsg.Add(string.Format("{0},\t{1}", new FileInfo(f).FullName, d));
            }
            return(listMsg);
        }
    }