private static void OutputThresholdReport(List <Tuple <Statement, Statement> > pairs, ProgramArguments programArgs) { CorrelationMatrix correlationMatrix = LoadCorrelationMatrix(programArgs); SimilarityAlgorithm sim = new SimilarityAlgorithm(correlationMatrix); StringBuilder sb = new StringBuilder(); foreach (Tuple <Statement, Statement> pair in pairs) { Statement s1 = StemStatement(pair.Item1); Statement s2 = StemStatement(pair.Item2); double s12 = sim.StatementSimilarityToStatement(s1, s2); double s21 = sim.StatementSimilarityToStatement(s2, s1); bool areEqual = sim.StatementEqualsToStatement(s1, s2); sb.AppendFormat( "{0},{1},{2},{2}\r\n", pair.Item1.ToString().Replace(',', '.'), pair.Item2.ToString().Replace(',', '.'), Math.Min(s12, s21), Math.Abs(s12 - s21)); } string reportName = "autoRSS_thresholdReport_" + Guid.NewGuid().ToString() + ".csv"; using (StreamWriter sw = new StreamWriter(reportName)) { sw.WriteLine(sb.ToString()); } Console.WriteLine("Report: " + reportName); }
private static void ScanTrainData(SimilarityAlgorithm sim) { StringBuilder sb = new StringBuilder(); foreach (string path in Directory.GetFiles("TrainData")) { string fileContents = ""; using (StreamReader sr = new StreamReader(path)) { fileContents = sr.ReadToEnd(); } Document document = ConstructDocument(fileContents); for (int i = 0; i < document.Statements.Length - 1; i += 2) { Statement s1 = document.Statements[i]; Statement s2 = document.Statements[i + 1]; double s12 = sim.StatementSimilarityToStatement(s1, s2); double s21 = sim.StatementSimilarityToStatement(s2, s1); sb.AppendFormat("{0},{1},{2},{3}\r\n", s1.ToString(), s2.ToString(), Math.Min(s12, s21), Math.Abs(s12 - s21)); } } string filename = "autorss_Threshold_" + Guid.NewGuid().ToString() + ".csv"; using (FileStream fs = new FileStream(filename, FileMode.CreateNew)) { StreamWriter sw = new StreamWriter(fs); sw.WriteLine(sb.ToString()); sw.Flush(); } Console.WriteLine("Threshold Report: " + filename); }