private void CreateTokenMatchGraph(OSPCResult r) { GraphPane g = new GraphPane(GraphRect, "Distribution of token / match", "-", "Token / match"); SetupGraph(g); var lst = r.Results.Select(i => (double)i.TokenCount / (double)i.MatchCount).OrderBy(i => i).ToArray(); var c = g.AddCurve("Token / match", Enumerable.Range(1, lst.Length).Select(i => (double)i).ToArray(), lst, Color.Red); c.Symbol.IsVisible = false; #if SHOW_DERIVATION_2 var derv_2 = lst.CalcDerv2(); c = g.AddCurve("Derivation 2", Enumerable.Range(1, derv_2.Length).Select(i => (double)i).ToArray(), derv_2.ToArray(), Color.Green); c.IsY2Axis = true; c.Symbol.IsVisible = false; #endif AddLine(g, r.AVG_TokenPerMatch, Color.Blue, "Avg"); AddLine(g, r.POI_TokenPerMatch, Color.Green, "POI"); g.AxisChange(); using (var img = g.GetImage()) { img.Save(Path.Combine(OutPath, "TokenMatchGraph.png"), ImageFormat.Png); } }
public void Create(Configuration cfg, OSPCResult r) { _cfg = cfg; if (!Directory.Exists(OutPath)) { Directory.CreateDirectory(OutPath); } if(!Directory.Exists(Path.Combine(OutPath, "Matches"))) { Directory.CreateDirectory(Path.Combine(OutPath, "Matches")); } CreateSummaryPage(r); CreateDetailPages(r); CreateFriendFinderPage(r); CreateTokenGraph(r); CreateTokenDetailGraph(r); CreatePercentGraph(r); CreateTokenMatchGraph(r); WriteStylesheet(); }
public void Create(Configuration cfg, OSPCResult r) { _cfg = cfg; if (!Directory.Exists(OutPath)) { Directory.CreateDirectory(OutPath); } if(!Directory.Exists(Path.Combine(OutPath, "Matches"))) { Directory.CreateDirectory(Path.Combine(OutPath, "Matches")); } CreateSummaryPage(r); CreateDetailPages(r); CreateFriendFinderPage(r); CreateTokenGraph(r); CreateTokenDetailGraph(r); CreatePercentGraph(r); CreateTokenMatchGraph(r); WriteStylesheet(); }
private void CreatePercentGraph(OSPCResult r) { GraphPane g = new GraphPane(GraphRect, "Distribution of % similarity", "-", "% similarity"); SetupGraph(g); var lst = r.Results.SelectMany(i => new[] { 100.0 * i.SimilarityA, 100.0 * i.SimilarityB }).OrderBy(i => i).ToArray(); var c = g.AddCurve("Similarity", Enumerable.Range(1, lst.Length).Select(i => (double)i).ToArray(), lst, Color.Red); c.Symbol.IsVisible = false; #if SHOW_DERIVATION_2 var derv_2 = lst.CalcDerv2(); c = g.AddCurve("Derivation 2", Enumerable.Range(1, derv_2.Length).Select(i => (double)i).ToArray(), derv_2.ToArray(), Color.Green); c.IsY2Axis = true; c.Symbol.IsVisible = false; #endif AddLine(g, 100.0 * r.AVG_Similarity, Color.Blue, "Avg"); AddLine(g, 100.0 * r.POI_Similarity, Color.Green, "POI"); g.AxisChange(); using (var img = g.GetImage(512, 256, 72.0f)) { img.Save(Path.Combine(OutPath, "PercentGraph.png"), ImageFormat.Png); } }
public void Create(Configuration cfg, OSPCResult r) { Console.WriteLine("Resultset: {0}", r.Results.Count); if (r.Results.Count > 0) { Console.WriteLine("Max Matches: {0}", r.Results.Max(m => m.MatchCount)); Console.WriteLine("Max Tokens: {0}", r.Results.Max(m => m.TokenCount)); } }
public void Create(Configuration cfg, OSPCResult r) { Console.WriteLine("Resultset: {0}", r.Results.Count); if (r.Results.Count > 0) { Console.WriteLine("Max Matches: {0}", r.Results.Max(m => m.MatchCount)); Console.WriteLine("Max Tokens: {0}", r.Results.Max(m => m.TokenCount)); } }
public void Create(Configuration cfg, OSPCResult r) { Console.WriteLine("{0, -20} {1,8} {2, -20} {3,8} {4, 8} {5, 8}", "A", "% A", "B", "% B", "Matches", "Tokens"); foreach (var result in r.Results.Take(100)) { Console.WriteLine("{0, -20} {1,8:n2} {2, -20} {3,8:n2} {4, 8} {4, 8}", result.A.FilePath.MaxLength(17, "...", true), 100.0 * result.SimilarityA, result.B.FilePath.MaxLength(17, "...", true), 100.0 * result.SimilarityB, result.MatchCount, result.TokenCount); } }
public void Create(Configuration cfg, OSPCResult r) { Console.WriteLine("{0, -20} {1,8} {2, -20} {3,8} {4, 8} {5, 8}", "A", "% A", "B", "% B", "Matches", "Tokens"); foreach (var result in r.Results.Take(100)) { Console.WriteLine("{0, -20} {1,8:n2} {2, -20} {3,8:n2} {4, 8} {4, 8}", result.A.FilePath.MaxLength(17, "...", true), 100.0 * result.SimilarityA, result.B.FilePath.MaxLength(17, "...", true), 100.0 * result.SimilarityB, result.MatchCount, result.TokenCount); } }
private void CreateFriendFinderPage(OSPCResult r) { using (var html = new StreamWriter(Path.Combine(OutPath, "friendfinder.html"))) { WriteHeader(html, "OSPC - FriendFinder", "", new TupleList<string, string>() { { "index.html", "Results" } }); WriteFriendFinderTitle(html); foreach (var f in r.Friends) { WriteFriendFinderLine(html, f); } WriteFriendFinderFooter(html); WriteFooter(html); html.Flush(); } }
private void CreateSummaryPage(OSPCResult r) { using (var html = new StreamWriter(Path.Combine(OutPath, "index.html"))) { WriteHeader(html, "OSPC", "", new TupleList<string, string>() { { "friendfinder.html", "Friend Finder" } }); WriteSummaryTitle(html); foreach (var result in r.Results.Where(i => i.SimilarityA >= _cfg.MIN_SIMILARITY || i.SimilarityB >= _cfg.MIN_SIMILARITY)) { WriteSummaryResultLine(html, result, GetDetailFileName(result)); } WriteSummaryFooter(html); WriteFooter(html); html.Flush(); } }
public void Create(Configuration cfg, OSPCResult r) { foreach (var result in r.Results.Take(10)) { Console.WriteLine(result.A.FilePath); Console.WriteLine(result.B.FilePath); Console.WriteLine("----------------------------"); Console.WriteLine("Matches: {0}", result.MatchCount); Console.WriteLine("Tokens: {0}", result.TokenCount); Console.WriteLine("% A: {0:n2}", 100.0 * result.SimilarityA); Console.WriteLine("% B: {0:n2}", 100.0 * result.SimilarityB); foreach (var m in result.Matches) { Console.WriteLine(" !: " + m.ToString()); } Console.WriteLine(); } }
public void Create(Configuration cfg, OSPCResult r) { foreach (var result in r.Results.Take(10)) { Console.WriteLine(result.A.FilePath); Console.WriteLine(result.B.FilePath); Console.WriteLine("----------------------------"); Console.WriteLine("Matches: {0}", result.MatchCount); Console.WriteLine("Tokens: {0}", result.TokenCount); Console.WriteLine("% A: {0:n2}", 100.0 * result.SimilarityA); Console.WriteLine("% B: {0:n2}", 100.0 * result.SimilarityB); foreach (var m in result.Matches) { Console.WriteLine(" !: " + m.ToString()); } Console.WriteLine(); } }
public void Create(Configuration cfg, OSPCResult r) { Console.WriteLine("{"); Console.WriteLine(" \"results\": ["); var resultCount = 0; foreach (var result in r.Results) { var aReader = new StreamReader(result.A.FilePath); var bReader = new StreamReader(result.B.FilePath); var matchesA = GetMatchedStrings(result, aReader, m => m.TokensA); var matchesB = GetMatchedStrings(result, bReader, m => m.TokensB); Console.WriteLine(" {"); Console.WriteLine(" \"{0}\": \"{1}\",", "fileA", result.A.FilePath.Replace('\\', '/')); Console.WriteLine(" \"{0}\": \"{1}\",", "fileB", result.B.FilePath.Replace('\\', '/')); Console.WriteLine(" \"{0}\": {1},", "matchCount", result.MatchCount); Console.WriteLine(" \"{0}\": {1},", "tokenCount", result.TokenCount); Console.WriteLine(" \"{0}\": {1:n2},", "simmA", 100.0 * result.SimilarityA); Console.WriteLine(" \"{0}\": {1:n2},", "simmB", 100.0 * result.SimilarityB); Console.WriteLine(" \"{0}\": [{1}],", "matchesA", BuildArrayJson(matchesA)); Console.WriteLine(" \"{0}\": [{1}]", "matchesB", BuildArrayJson(matchesB)); if (resultCount == r.Results.Count - 1) { Console.WriteLine(" }"); } else { Console.WriteLine(" },"); } /* BuildArrayJson(matchesA), * "matchesB", * BuildArrayJson(matchesB)*/ resultCount++; } Console.WriteLine(" ]"); Console.WriteLine("}"); }
public async void Check() { if (!CanCheck()) { return; } IsRunning = true; try { await Task.Run(() => { var watch = Stopwatch.StartNew(); var comparer = new Comparer(Configuration, (IProgressReporter)this); AddMessage(string.Format("Comparing {0} files ", Submissions.Count)); var compareResult = comparer.Compare(Submissions.Select(i => i.Submission).ToArray()); AddMessage(string.Format(" finished; time: {0:n2} sec.", watch.Elapsed.TotalSeconds)); AddMessage("Creating statistics"); var result = OSPCResult.Create(compareResult); var friends = new OSPC.FriendFinder(Configuration); friends.Find(result, compareResult); AddMessage(string.Format(" finished; time: {0:n2} sec.", watch.Elapsed.TotalSeconds)); AddMessage("Creating reports"); var html = new OSPC.Reporter.Html.HtmlReporter(HtmlReportPath, (IProgressReporter)this); html.Create(this.Configuration, result); System.Diagnostics.Process.Start(System.IO.Path.Combine(html.OutPath, "index.html")); AddMessage(string.Format(" finished in total {0:n2} sec.", watch.Elapsed.TotalSeconds)); SaveUserSettings(); }); } finally { IsRunning = false; } }
private void CreateDetailPages(OSPCResult r) { int counter = 0; int max = r.Results.Count; _progress.Start(); object _lock = new object(); #if SINGLE_THREADED foreach(var result in r.Results) #else Parallel.ForEach(r.Results.Where(i => i.SimilarityA >= _cfg.MIN_SIMILARITY || i.SimilarityB >= _cfg.MIN_SIMILARITY), result => #endif { WriteDetail(result, GetDetailFileName(result)); lock (_lock) { _progress.Progress((double)++counter / (double)max); } } #if !SINGLE_THREADED ); #endif _progress.End(); }
private void CreateTokenMatchGraph(OSPCResult r) { GraphPane g = new GraphPane(GraphRect, "Distribution of token / match", "-", "Token / match"); SetupGraph(g); var lst = r.Results.Select(i => (double)i.TokenCount / (double)i.MatchCount).OrderBy(i => i).ToArray(); var c = g.AddCurve("Token / match", Enumerable.Range(1, lst.Length).Select(i => (double)i).ToArray(), lst, Color.Red); c.Symbol.IsVisible = false; #if SHOW_DERIVATION_2 var derv_2 = lst.CalcDerv2(); c = g.AddCurve("Derivation 2", Enumerable.Range(1, derv_2.Length).Select(i => (double)i).ToArray(), derv_2.ToArray(), Color.Green); c.IsY2Axis = true; c.Symbol.IsVisible = false; #endif AddLine(g, r.AVG_TokenPerMatch, Color.Blue, "Avg"); AddLine(g, r.POI_TokenPerMatch, Color.Green, "POI"); g.AxisChange(); using (var img = g.GetImage()) { img.Save(Path.Combine(OutPath, "TokenMatchGraph.png"), ImageFormat.Png); } }
private void CreateSummaryPage(OSPCResult r) { using (var html = new StreamWriter(Path.Combine(OutPath, "index.html"))) { WriteHeader(html, "OSPC", "", new TupleList<string, string>() { { "friendfinder.html", "Friend Finder" } }); WriteSummaryTitle(html); foreach (var result in r.Results.Where(i => i.SimilarityA >= _cfg.MIN_SIMILARITY || i.SimilarityB >= _cfg.MIN_SIMILARITY)) { WriteSummaryResultLine(html, result, GetDetailFileName(result)); } WriteSummaryFooter(html); WriteFooter(html); html.Flush(); } }
private void CreatePercentGraph(OSPCResult r) { GraphPane g = new GraphPane(GraphRect, "Distribution of % similarity", "-", "% similarity"); SetupGraph(g); var lst = r.Results.SelectMany(i => new[] { 100.0 * i.SimilarityA, 100.0 * i.SimilarityB }).OrderBy(i => i).ToArray(); var c = g.AddCurve("Similarity", Enumerable.Range(1, lst.Length).Select(i => (double)i).ToArray(), lst, Color.Red); c.Symbol.IsVisible = false; #if SHOW_DERIVATION_2 var derv_2 = lst.CalcDerv2(); c = g.AddCurve("Derivation 2", Enumerable.Range(1, derv_2.Length).Select(i => (double)i).ToArray(), derv_2.ToArray(), Color.Green); c.IsY2Axis = true; c.Symbol.IsVisible = false; #endif AddLine(g, 100.0 * r.AVG_Similarity, Color.Blue, "Avg"); AddLine(g, 100.0 * r.POI_Similarity, Color.Green, "POI"); g.AxisChange(); using (var img = g.GetImage(512, 256, 72.0f)) { img.Save(Path.Combine(OutPath, "PercentGraph.png"), ImageFormat.Png); } }
private void CreateFriendFinderPage(OSPCResult r) { using (var html = new StreamWriter(Path.Combine(OutPath, "friendfinder.html"))) { WriteHeader(html, "OSPC - FriendFinder", "", new TupleList<string, string>() { { "index.html", "Results" } }); WriteFriendFinderTitle(html); foreach (var f in r.Friends) { WriteFriendFinderLine(html, f); } WriteFriendFinderFooter(html); WriteFooter(html); html.Flush(); } }
private void CreateDetailPages(OSPCResult r) { int counter = 0; int max = r.Results.Count; _progress.Start(); object _lock = new object(); #if SINGLE_THREADED foreach(var result in r.Results) #else Parallel.ForEach(r.Results.Where(i => i.SimilarityA >= _cfg.MIN_SIMILARITY || i.SimilarityB >= _cfg.MIN_SIMILARITY), result => #endif { WriteDetail(result, GetDetailFileName(result)); lock (_lock) { _progress.Progress((double)++counter / (double)max); } } #if !SINGLE_THREADED ); #endif _progress.End(); }