예제 #1
0
        public void Compare_1()
        {
            var manu = "00034567890123400";
            var book = "01234567890123456789";
            var xc   = new XComparer(manu, 5);
            var res  = xc.Compare(book);

            Assert.AreEqual(3, res[0].ManStart);
            Assert.AreEqual(12, res[0].Length);
        }
예제 #2
0
        public void Compare_4()
        {
            int    L = 10000, D = 1000;
            string book = File.ReadAllText(@"Resources\Text1.txt");
            var    manu = new string('0', L) + book.Substring(L, D) + new string('0', L);
            var    xc   = new XComparer(manu, 100);
            var    res  = xc.Compare(book);

            Assert.AreEqual(L, res[0].ManStart);
            Assert.AreEqual(D, res[0].Length);
        }
예제 #3
0
        private int Analize()
        {
            Book manual = new Book(name: "", source: File.ReadAllText(manualPath));

            XComparer comparer = new XComparer(manual.Digest, GetFrigmentSize());

            string rootPath = Path.GetDirectoryName(manualPath);

            int max = 0;

            reportBox.Items.Clear();
            foreach (string bookPath in Directory.GetFiles(rootPath, "*.txt"))
            {
                if (bookPath == manualPath)
                {
                    continue;
                }

                Book book = new Book(
                    name: Path.GetFileName(bookPath),
                    source: File.ReadAllText(bookPath));

                var report = comparer.Compare(book.Digest);

                foreach (var reportItem in report)
                {
                    reportItem.Book   = book;
                    reportItem.Manual = manual;

                    reportBox.Items.Add(reportItem);
                }

                if (report.Count > 0)
                {
                    max = Math.Max(max, report.Max(r => r.Length));
                }
            }
            return(max);
        }