void XamlIsEqual(string input1, string input2) { var diff = new StringWriter(); if (!CodeComparer.Compare(input1, input2, diff, NormalizeLine)) { Assert.Fail(diff.ToString()); } }
static void Main(string[] args) { InitIO(); var n = int.Parse(Console.ReadLine()); Console.Error.WriteLine("Input files: {0}", n); var graph = new Graph <string>(); var comparer = new CodeComparer(new CodeAnalyzerBuilder()); var signatures = new Signatures(); var files = new string[n]; for (var i = 0; i < n; i++) { files[i] = Console.ReadLine(); var language = Path.GetExtension(files[i]); var code = File.ReadAllText(files[i]); code = signatures.FormatCode(code); var codeAnalyzer = new SuffixTreeCodeAnalyzer(language, code); graph.AddVertex(files[i]); comparer.Register(files[i], language, code); if ((i + 1) % 100 == 0) { OnProgress("Parsed: ", i + 1, n); } } var maximum = (long)(n) * (long)(n - 1) / 2; var progress = (long)0; OnProgress("Compared: ", progress, maximum); for (var i = 0; i < n; i++) { for (var j = i + 1; j < n; j++) { if (++progress % 10000 == 0) { OnProgress(progress, maximum); } if (files[i].Contains('-') && files[j].Contains('-')) { var id1 = files[i].Substring(0, files[i].IndexOf('-')); var id2 = files[j].Substring(0, files[j].IndexOf('-')); if (id1 == id2) { continue; } } decimal compare = comparer.Compare(files[i], files[j]); if (compare > 0.33M) { Console.Error.WriteLine("{0} | {1} -> {2:0.00}%", files[i], files[j], compare * 100); graph.AddEdge(files[i], files[j]); } } } OnProgress(progress, maximum); var res = from c in graph.GetConnectedComponents() where c.Count >= 2 select c; Console.WriteLine(res.Count()); Console.Error.WriteLine(res.Count()); foreach (var g in res) { foreach (var file in g.Verticies) { Console.Write(file + " "); Console.Error.Write(file + " "); } Console.WriteLine(); Console.Error.WriteLine(); } Console.Out.Dispose(); }