public static void Export(TLSimilarityMatrix answerSet, string sourceId, string targetId, string outputPath) { if (answerSet == null) { throw new TraceLabSDK.ComponentException("Received null answer similarity matrix"); } System.Xml.XmlWriterSettings settings = new System.Xml.XmlWriterSettings(); settings.Indent = true; settings.CloseOutput = true; settings.CheckCharacters = true; //create file using (System.Xml.XmlWriter writer = System.Xml.XmlWriter.Create(outputPath, settings)) { writer.WriteStartDocument(); writer.WriteStartElement("answer_set"); WriteAnswerSetInfo(writer, sourceId, targetId); WriteLinks(answerSet, writer); writer.WriteEndElement(); //answer_set writer.WriteEndDocument(); writer.Close(); } System.Diagnostics.Trace.WriteLine("File created , you can find the file " + outputPath); }
/// <summary> /// Exports a TLSimilarityMatrix to CSV format /// </summary> /// <param name="similarityMatrix">Matrix</param> /// <param name="outputPath">Output file path</param> public static void ExportCSV(TLSimilarityMatrix similarityMatrix, string outputPath) { if (similarityMatrix == null) { throw new DevelopmentKitException("Received similarity matrix is null!"); } if (outputPath == null) { throw new DevelopmentKitException("Output path cannot be null."); } if (!System.IO.Path.IsPathRooted(outputPath)) { throw new DevelopmentKitException(String.Format("Absolute output path is required. Given path is '{0}'", outputPath)); } if (outputPath.EndsWith(".csv", StringComparison.CurrentCultureIgnoreCase) == false) { outputPath = outputPath + ".csv"; } using (System.IO.TextWriter writeFile = new StreamWriter(outputPath)) { WriteMatrixCSV(similarityMatrix, writeFile); writeFile.Flush(); writeFile.Close(); } }
public void SimilarityMatrixRawSerializationTest() { string[] sources = new string[] { "source1", "source2", "source3", "source4", "source5", "source6", "source7", "source8", "source9", "source10" }; string[] targets = new string[] { "target1", "target2", "target3", "target4", "target5", "target6", "target7", "target8", "target9", "target10" }; TLSimilarityMatrix matrixIn = new TLSimilarityMatrix(); for (int i = 0; i < sources.Length; i++) { matrixIn.AddLink(sources[i], targets[i], (double)i); } BinaryWriter binWriter = new BinaryWriter(new MemoryStream()); BinaryReader binReader = new BinaryReader(binWriter.BaseStream); matrixIn.WriteData(binWriter); binReader.BaseStream.Position = 0; TLSimilarityMatrix matrixOut = new TLSimilarityMatrix(); matrixOut.ReadData(binReader); Assert.AreEqual(matrixIn.Count, matrixOut.Count); StringHashSet setIn = matrixIn.SourceArtifactsIds; StringHashSet setOut = matrixOut.SourceArtifactsIds; foreach (string artifact in setIn) { Assert.IsTrue(setOut.Contains(artifact)); } }
public static DataSetPairs Compute(TLSimilarityMatrix sims, TLSimilarityMatrix oracle, RecallLevel recall) { TLSimilarityMatrix matrix = Similarities.CreateMatrix(MetricsUtil.GetLinksAtRecall(sims, oracle, recall)); matrix.Threshold = double.MinValue; DataSetPairs pairs = new DataSetPairs(); foreach (string sourceArtifact in oracle.SourceArtifactsIds) { TLLinksList links = matrix.GetLinksAboveThresholdForSourceArtifact(sourceArtifact); links.Sort(); int totalCorrect = oracle.GetLinksAboveThresholdForSourceArtifact(sourceArtifact).Count; int numCorrect = 0; int totalRead = 0; double totalAvgPrecision = 0.0; foreach (TLSingleLink link in links) { totalRead++; if (oracle.IsLinkAboveThreshold(link.SourceArtifactId, link.TargetArtifactId)) { numCorrect++; totalAvgPrecision += numCorrect / (double)totalRead; } } pairs.PrecisionData.Add(new KeyValuePair<string, double>(sourceArtifact, numCorrect / Convert.ToDouble(links.Count))); pairs.RecallData.Add(new KeyValuePair<string, double>(sourceArtifact, Convert.ToDouble(numCorrect) / totalCorrect)); pairs.AveragePrecisionData.Add(new KeyValuePair<string, double>(sourceArtifact, totalAvgPrecision / totalCorrect)); } pairs.MeanAveragePrecisionData.Add(new KeyValuePair<string, double>("#TOTAL", DataSetPairsCollection.CalculateAverage(pairs.AveragePrecisionData))); return pairs; }
/// <summary> /// Exports an answer matrix to a file. /// </summary> /// <param name="answerMatrix">Answer matrix</param> /// <param name="filename">Output file path</param> public static void Export(TLSimilarityMatrix answerMatrix, string filename) { TextWriter tw = null; try { tw = new StreamWriter(filename); foreach (string sourceID in answerMatrix.SourceArtifactsIds) { tw.Write(sourceID); foreach (string targetID in answerMatrix.GetSetOfTargetArtifactIdsAboveThresholdForSourceArtifact(sourceID)) { tw.Write(" " + targetID); } tw.WriteLine(); } tw.Flush(); tw.Close(); } catch (Exception e) { if (tw != null) { tw.Close(); } throw new DevelopmentKitException("There was an exception writing to file (" + filename + ")", e); } }
public static void ComputeMetrics(TLSimilarityMatrix sims, TLSimilarityMatrix oracle, RecallLevel level, out TLKeyValuePairsList precision, out TLKeyValuePairsList recall, out TLKeyValuePairsList avgPrecision, out TLKeyValuePairsList meanAvgPrecision) { TLLinksList links = MetricsUtil.GetLinksAtRecall(sims, oracle, level); int numCorrect = 0; int totalRead = 0; double totalAvgPrecision = 0.0; foreach (TLSingleLink link in links) { totalRead++; if (oracle.IsLinkAboveThreshold(link.SourceArtifactId, link.TargetArtifactId)) { numCorrect++; totalAvgPrecision += numCorrect / (double) totalRead; } } // temporary precision = new TLKeyValuePairsList(); precision.Add(new KeyValuePair<string, double>("#TOTAL", numCorrect / Convert.ToDouble(links.Count))); recall = new TLKeyValuePairsList(); recall.Add(new KeyValuePair<string, double>("#TOTAL", Math.Ceiling(oracle.Count * RecallLevelUtil.RecallValue(level)) / oracle.Count)); avgPrecision = new TLKeyValuePairsList(); avgPrecision.Add(new KeyValuePair<string, double>("#TOTAL", totalAvgPrecision / oracle.Count)); meanAvgPrecision = new TLKeyValuePairsList(); meanAvgPrecision.Add(new KeyValuePair<string,double>("#TOTAL", MeanAveragePrecision.Compute(Similarities.CreateMatrix(links), oracle))); }
/// <summary> /// Computes cosine similarities between two TermDocumentMatrices. /// Cosine similarity is defined as (dot product) / (length * length) /// </summary> /// <param name="m1">Binary document matrix</param> /// <param name="m2">tf-idf weighted document matrix</param> /// <returns>Similarity matrix</returns> public static TLSimilarityMatrix ComputeCosine(TermDocumentMatrix m1, TermDocumentMatrix m2) { TLSimilarityMatrix sims = new TLSimilarityMatrix(); List<TermDocumentMatrix> matrices = TermDocumentMatrix.Equalize(m1, m2); for (int i = 0; i < m1.NumDocs; i++) { TLLinksList links = new TLLinksList(); for (int j = 0; j < m2.NumDocs; j++) { double lengthProduct = ComputeLength(matrices[0].GetDocument(i)) * ComputeLength(matrices[1].GetDocument(j)); if (lengthProduct == 0.0) { links.Add(new TLSingleLink(m1.GetDocumentName(i), m2.GetDocumentName(j), 0.0)); } else { links.Add(new TLSingleLink(m1.GetDocumentName(i), m2.GetDocumentName(j), ComputeDotProduct(matrices[0].GetDocument(i), matrices[1].GetDocument(j)) / lengthProduct)); } } links.Sort(); foreach (TLSingleLink link in links) { sims.AddLink(link.SourceArtifactId, link.TargetArtifactId, link.Score); } } return sims; }
/// <summary> /// Imports a file in the form (each line): /// SOURCE TARGET SCORE /// </summary> /// <param name="filename">Similarities file</param> /// <returns>Similarity matrix</returns> public static TLSimilarityMatrix Import(String filename) { StreamReader file = new StreamReader(filename); TLSimilarityMatrix answer = new TLSimilarityMatrix(); String line; int num = 0; while ((line = file.ReadLine()) != null) { num++; if (String.IsNullOrWhiteSpace(line)) continue; try { String[] artifacts = line.Split(); String source = artifacts[0]; String target = artifacts[1]; double score = Convert.ToDouble(artifacts[2]); answer.AddLink(source, target, score); } catch (IndexOutOfRangeException e) { file.Close(); throw new InvalidDataException("Invalid data format on line " + num + " of file:" + filename, e); } } file.Close(); return answer; }
/// <summary> /// Collapses overloaded source artifacts, assigning the best score. /// </summary> /// <param name="matrix">Similarities</param> /// <returns>Collapsed artifacts</returns> public static TLSimilarityMatrix CollapseOverloadedTargets(TLSimilarityMatrix matrix) { Dictionary<string, Dictionary<string, double>> pseudomatrix = new Dictionary<string, Dictionary<string, double>>(); foreach (TLSingleLink link in matrix.AllLinks) { if (!pseudomatrix.ContainsKey(link.SourceArtifactId)) { pseudomatrix.Add(link.SourceArtifactId, new Dictionary<string,double>()); } int startIndex = link.TargetArtifactId.IndexOf('('); string target = (startIndex > 0) ? link.TargetArtifactId.Substring(0, startIndex) : link.TargetArtifactId; if (!pseudomatrix[link.SourceArtifactId].ContainsKey(target)) { pseudomatrix[link.SourceArtifactId].Add(target, link.Score); } else { if (link.Score > pseudomatrix[link.SourceArtifactId][target]) { pseudomatrix[link.SourceArtifactId][target] = link.Score; } } } TLSimilarityMatrix collapsedMatrix = new TLSimilarityMatrix(); foreach (string sourceID in pseudomatrix.Keys) { foreach (string targetID in pseudomatrix[sourceID].Keys) { collapsedMatrix.AddLink(sourceID, targetID, pseudomatrix[sourceID][targetID]); } } return collapsedMatrix; }
/// <summary> /// Copy constructor /// </summary> public TLSimilarityMatrix(TLSimilarityMatrix inMatrix) { m_cacheOfLinksPerSourceArtifacts = inMatrix.m_cacheOfLinksPerSourceArtifacts; m_cacheOfSetsPerSourceArtifacts = inMatrix.m_cacheOfSetsPerSourceArtifacts; m_matrix = inMatrix.m_matrix; m_name = inMatrix.m_name; m_threshold = inMatrix.m_threshold; }
/// <summary> /// Constructor for the precision-recall curve computation /// </summary> /// <param name="candidateMatrix">Candidate links</param> /// <param name="answerMatrix">Answer matrix</param> public PrecisionRecallCurveComputation(TLSimilarityMatrix candidateMatrix, TLSimilarityMatrix answerMatrix) : base() { _matrix = candidateMatrix; _oracle = answerMatrix; _precisionFormat = String.Format("{{0:D{0}}}_Precision", Math.Floor(Math.Log10(candidateMatrix.Count))); _recallFormat = String.Format("{{0:D{0}}}_Recall", Math.Floor(Math.Log10(candidateMatrix.Count))); }
public static void ExtractFeature(ref TLSimilarityMatrix sims, ref TLSimilarityMatrix newsims, string tracedir) { foreach (String file in Directory.GetFiles(tracedir)) { String feature = Similarities.ExtractFeatureID(file); Dictionary<string, int> trace = Lookup(feature, tracedir); RemoveNonExecutedMethods(ref sims, ref newsims, feature, trace); } }
public static TLSimilarityMatrix CreateMatrix(TLLinksList list) { TLSimilarityMatrix matrix = new TLSimilarityMatrix(); foreach (TLSingleLink link in list) { matrix.AddLink(link.SourceArtifactId, link.TargetArtifactId, link.Score); } return matrix; }
public static DataSetPairsCollection ComputeAll(TLSimilarityMatrix sims, TLSimilarityMatrix oracle) { DataSetPairsCollection dspc = new DataSetPairsCollection(); foreach (RecallLevel level in Enum.GetValues(typeof(RecallLevel))) { dspc.Add(Compute(sims, oracle, level)); } return dspc; }
/// <summary> /// Exports TLSimilarityMatrix to file in the form (each line): /// SOURCE TARGET SCORE /// </summary> /// <param name="matrix">Similarity matrix</param> public static void Export(TLSimilarityMatrix matrix, string filename) { TextWriter file = new StreamWriter(filename); foreach (TLSingleLink link in matrix.AllLinks) { file.WriteLine("{0} {1} {2}", link.SourceArtifactId, link.TargetArtifactId, link.Score); } file.Flush(); file.Close(); }
/// <summary> /// Normalizes a similarity matrix /// </summary> /// <param name="matrix">Similarity matrix</param> /// <returns>Normalized similarity matrix</returns> public static TLSimilarityMatrix Normalize(TLSimilarityMatrix matrix) { TLSimilarityMatrix norm = new TLSimilarityMatrix(); double mean = TLSimilarityMatrixUtil.AverageSimilarity(matrix); double stdDev = TLSimilarityMatrixUtil.SimilarityStandardDeviation(matrix); foreach (TLSingleLink link in matrix.AllLinks) { norm.AddLink(link.SourceArtifactId, link.TargetArtifactId, (link.Score - mean) / stdDev); } return norm; }
private static void MyMetrics(ref Info info, string output, TLSimilarityMatrix matrix, TLSimilarityMatrix oracle) { DataSetPairsCollection metrics = OverallMetricsComputation.ComputeAll(matrix, oracle); TextWriter dataFile = File.CreateText(output); for (int i = 0, j = 10; i < metrics.Count; i++, j += 10) { dataFile.WriteLine("{0} {1}", j, metrics[i].PrecisionData[0].Value); } dataFile.Flush(); dataFile.Close(); }
public static void Split(ref TLSimilarityMatrix original, Dictionary<int, string> qmap, ref TLSimilarityMatrix bugs, ref TLSimilarityMatrix features, ref TLSimilarityMatrix patch) { foreach (TLSingleLink link in original.AllLinks) { string feature = qmap[Convert.ToInt32(link.SourceArtifactId)]; if (feature == Trace.GetFeatureSetType(FeatureSet.Bugs)) bugs.AddLink(link.SourceArtifactId, link.TargetArtifactId, link.Score); else if (feature == Trace.GetFeatureSetType(FeatureSet.Features)) features.AddLink(link.SourceArtifactId, link.TargetArtifactId, link.Score); else if (feature == Trace.GetFeatureSetType(FeatureSet.Patch)) patch.AddLink(link.SourceArtifactId, link.TargetArtifactId, link.Score); } }
private static void RemoveNonFeature(ref TLSimilarityMatrix sims, FeatureSet set, Dictionary<int, string> qmap) { TLSimilarityMatrix target = new TLSimilarityMatrix(); string feature = GetFeatureSetType(set); foreach (TLSingleLink link in sims.AllLinks) { if (qmap[Convert.ToInt32(link.SourceArtifactId)] == feature) { target.AddLink(link.SourceArtifactId, link.TargetArtifactId, link.Score); } } sims = target; }
internal static void CompareResults(TLSimilarityMatrix oracle, TLSimilarityMatrix results, IEnumerable<string> rawMethods) { Console.WriteLine("Comparing results..."); Assert.AreEqual(oracle.Count, results.Count); foreach (string oracleMethod in oracle.GetSetOfTargetArtifactIdsAboveThresholdForSourceArtifact("trace")) { string rawMethod = rawMethods.ElementAt(Convert.ToInt32(oracleMethod) - 1); string method = rawMethod.Substring(0, rawMethod.IndexOf('(')); //Console.WriteLine(oracleMethod + ": " + method); Assert.IsTrue(results.IsLinkAboveThreshold("trace", method)); Assert.AreEqual(oracle.GetScoreForLink("trace", oracleMethod), results.GetScoreForLink("trace", method), Settings.Default.DoublePrecision); } }
public static int GetLinkPos(TLSimilarityMatrix sims, TLSingleLink link) { TLLinksList list = sims.AllLinks; list.Sort(); int pos = 1; foreach (TLSingleLink query in list) { if (query.SourceArtifactId.Equals(link.SourceArtifactId) && query.TargetArtifactId.Equals(link.TargetArtifactId)) return pos; pos++; } return -1; }
internal static TLSimilarityMatrix GenerateOracle(string rankFile, string mapFile) { Console.WriteLine("Generating oracle..."); IEnumerable<double> ranks = Generics.ImportDoubles(rankFile, false); IEnumerable<string> map = Generics.ImportStrings(mapFile); Assert.AreEqual(map.Count(), ranks.Count()); TLSimilarityMatrix oracle = new TLSimilarityMatrix(); for (int i = 0; i < map.Count(); i++) { oracle.AddLink("trace", map.ElementAt(i), ranks.ElementAt(i)); } return oracle; }
public static TLSimilarityMatrix Compute(TLSimilarityMatrix matrix, TLSimilarityMatrix relationships) { // create pseudo matrix for easy lookup // Dictionary<sourceID, Dictionary<targetID, score>> Dictionary<string, Dictionary<string, double>> storage = new Dictionary<string, Dictionary<string, double>>(); foreach (TLSingleLink link in matrix.AllLinks) { if (!storage.ContainsKey(link.SourceArtifactId)) { storage.Add(link.SourceArtifactId, new Dictionary<string, double>()); } storage[link.SourceArtifactId].Add(link.TargetArtifactId, link.Score); } #if UseDelta // compute delta double delta = SharedUtils.ComputeDelta(matrix); #endif // iterate over every (source, target) pair TLLinksList links = matrix.AllLinks; links.Sort(); foreach (TLSingleLink link in links) { // get the set of target artifacts related to link.TargetArtifactId // then update the value of (link.SourceArtifactId, relatedArtifact) by delta foreach (string relatedArtifact in relationships.GetSetOfTargetArtifactIdsAboveThresholdForSourceArtifact(link.TargetArtifactId)) { #if UseDelta storage[link.SourceArtifactId][relatedArtifact] += storage[link.SourceArtifactId][relatedArtifact] * delta; #else storage[link.SourceArtifactId][relatedArtifact] += storage[link.SourceArtifactId][relatedArtifact] * 0.1; #endif } } // build new matrix TLLinksList newLinks = new TLLinksList(); foreach (string source in storage.Keys) { foreach (string target in storage[source].Keys) { newLinks.Add(new TLSingleLink(source, target, storage[source][target])); } } newLinks.Sort(); TLSimilarityMatrix newMatrix = new TLSimilarityMatrix(); foreach (TLSingleLink link in newLinks) { newMatrix.AddLink(link.SourceArtifactId, link.TargetArtifactId, link.Score); } return newMatrix; }
/// <summary> /// Performs an affine transformation on two similarity matrices. /// </summary> /// <param name="large">Large expert</param> /// <param name="small">Small expert</param> /// <param name="lambda">Weight given to large expert</param> /// <returns>Transformed similarities</returns> public static TLSimilarityMatrix Transform(TLSimilarityMatrix large, TLSimilarityMatrix small, double lambda) { TLSimilarityMatrix largeNormal = Normalize(large); TLSimilarityMatrix smallNormal = Normalize(small); TLSimilarityMatrix combined = new TLSimilarityMatrix(); foreach (TLSingleLink largeLink in largeNormal.AllLinks) { double smallLink = smallNormal.GetScoreForLink(largeLink.SourceArtifactId, largeLink.TargetArtifactId); combined.AddLink(largeLink.SourceArtifactId, largeLink.TargetArtifactId, Combine(largeLink.Score, smallLink, lambda)); } return combined; }
/// <summary> /// FORMAT /// ====== /// Line 1 - "","UC","CC","Similarity","Oracle","Precision","Recall","feedback" /// Line 2+ - values /// </summary> /// <param name="path"></param> /// <returns></returns> public static TLSimilarityMatrix Import(string path) { TLSimilarityMatrix matrix = new TLSimilarityMatrix(); matrix.Threshold = Double.MinValue; TextReader file = new StreamReader(path); file.ReadLine(); string line; while ((line = file.ReadLine()) != null) { string[] item = line.Split(new char[] { ',', '"' }, StringSplitOptions.RemoveEmptyEntries); matrix.AddLink(item[1], item[2], Convert.ToDouble(item[3])); } return matrix; }
private static void CreateExcelReport(TLSimilarityMatrix similarityMatrix, TLSimilarityMatrix answerMatrix, string outputPath) { if (similarityMatrix == null) { throw new ComponentException("Received similarity matrix is null!"); } if (answerMatrix == null) { throw new ComponentException("Received answer similarity matrix is null!"); } if (outputPath == null) { throw new ComponentException("Output path cannot be null."); } if (!System.IO.Path.IsPathRooted(outputPath)) { throw new ComponentException(String.Format("Absolute output path is required. Given path is '{0}'", outputPath)); } if (outputPath.EndsWith(".xsl", StringComparison.CurrentCultureIgnoreCase) == false) { outputPath = outputPath + ".xsl"; } Excel.Application xlApp; Excel.Workbook xlWorkBook; Excel.Worksheet xlWorkSheet; object misValue = System.Reflection.Missing.Value; xlApp = new Excel.Application(); xlWorkBook = xlApp.Workbooks.Add(misValue); xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1); ReadSimilarityMatrixToExcelWorksheet(similarityMatrix, answerMatrix, xlWorkSheet); xlWorkBook.SaveAs(outputPath, Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue); xlWorkBook.Close(true, misValue, misValue); xlApp.Quit(); releaseObject(xlWorkSheet); releaseObject(xlWorkBook); releaseObject(xlApp); }
public static DataSetPairs Compute(TLSimilarityMatrix sims, TLSimilarityMatrix oracle, RecallLevel level) { TLKeyValuePairsList precision; TLKeyValuePairsList recall; TLKeyValuePairsList avgPrecision; TLKeyValuePairsList meanAvgPrecision; ComputeMetrics(sims, oracle, level, out precision, out recall, out avgPrecision, out meanAvgPrecision); return new DataSetPairs { Name = RecallLevelUtil.ShortRecallString(level), PrecisionData = precision, RecallData = recall, AveragePrecisionData = avgPrecision, MeanAveragePrecisionData = meanAvgPrecision, }; }
/// <summary> /// Compute the delta value for each source artifact, then return the median of the delta values /// </summary> /// <param name="matrix"></param> /// <returns></returns> public static double ComputeDelta(TLSimilarityMatrix matrix) { List<double> DeltaLookup = new List<double>(); foreach (string source in matrix.SourceArtifactsIds) { DeltaLookup.Add(ComputeDeltaForSourceArtifact(matrix, source)); } DeltaLookup.Sort(); if (DeltaLookup.Count % 2 == 0) { return (DeltaLookup[DeltaLookup.Count / 2] + DeltaLookup[(DeltaLookup.Count / 2) + 1]) / 2.0; } else { return DeltaLookup[Convert.ToInt32(Math.Ceiling(DeltaLookup.Count / 2.0))]; } }
private static void WriteLinks(TLSimilarityMatrix answerSet, System.Xml.XmlWriter writer) { writer.WriteStartElement("links"); foreach (TLSingleLink link in answerSet.AllLinks) { writer.WriteStartElement("link"); writer.WriteElementString("source_artifact_id", link.SourceArtifactId.Trim()); writer.WriteElementString("target_artifact_id", link.TargetArtifactId.Trim()); writer.WriteElementString("confidence_score", link.Score.ToString().Trim()); writer.WriteEndElement(); } writer.WriteEndElement(); // artifacts }
private static void ReadSimilarityMatrixToFile(TLSimilarityMatrix similarityMatrix, System.IO.TextWriter writeFile) { //header writeFile.WriteLine("Source Artifact Id,Target Artifact Id,Probability"); foreach (string sourceArtifact in similarityMatrix.SourceArtifactsIds) { var traceLinks = similarityMatrix.GetLinksAboveThresholdForSourceArtifact(sourceArtifact); traceLinks.Sort(); foreach (TLSingleLink link in traceLinks) { writeFile.WriteLine("{0},{1},{2}", link.SourceArtifactId, link.TargetArtifactId, link.Score); } } }
private static void WriteSims(ref Info info, CSMR13DataSet dataset, TLSimilarityMatrix oracle, string model) { TextWriter Output = File.CreateText(info.OutputDirectory + @"\CheckLinkOrder\" + SharedUtils.CleanFileName(dataset.Name) + "." + model + ".txt"); TLSimilarityMatrix sims = Similarities.Import(info.ResultsDirectory.FullName + @"\" + SharedUtils.CleanFileName(dataset.Name) + @"\sims\" + model + ".sims"); TLLinksList simList = sims.AllLinks; simList.Sort(); int pos = 1; foreach (TLSingleLink link in simList) { if (oracle.IsLinkAboveThreshold(link.SourceArtifactId, link.TargetArtifactId)) { Output.WriteLine("[{0}]\t{1}\t{2}\t{3}", pos, link.SourceArtifactId, link.TargetArtifactId, link.Score); } pos++; } Output.Flush(); Output.Close(); }