public static List <CSMR13DataSet> Import(string filename) { XmlDocument XMLdoc = new XmlDocument(); XMLdoc.Load(filename); string[] s = filename.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries); StringBuilder path = new StringBuilder(); for (long i = 0; i < s.Length - 1; i++) { path.Append(s[i]); path.Append("\\"); } path.Append(XMLdoc.GetElementsByTagName("Datasets")[0].Attributes["Directory"].Value.Replace('/', '\\')); List <CSMR13DataSet> datasets = new List <CSMR13DataSet>(); XmlNodeList nodelist = XMLdoc.GetElementsByTagName("Dataset"); foreach (XmlNode node in nodelist) { CSMR13DataSet dataset = new CSMR13DataSet(); dataset.SourceArtifacts = path + node["Corpus"].Attributes["Directory"].Value + node["Corpus"]["SourceArtifacts"].InnerText + "#" + node["Corpus"]["SourceArtifacts"].Attributes["Extension"].Value; dataset.TargetArtifacts = path + node["Corpus"].Attributes["Directory"].Value + node["Corpus"]["TargetArtifacts"].InnerText + "#" + node["Corpus"]["TargetArtifacts"].Attributes["Extension"].Value; dataset.Oracle = path + node["Corpus"].Attributes["Directory"].Value + node["Corpus"]["Oracle"].InnerText; dataset.Name = node.Attributes["Name"].Value; dataset.Relationships = path + node["Corpus"].Attributes["Directory"].Value + node["Corpus"]["Relationships"].InnerText; dataset.Stopwords = path + node["Corpus"].Attributes["Directory"].Value + node["Corpus"]["Stopwords"].InnerText; datasets.Add(dataset); } return(datasets); }
public static void Run(ref Info info, CSMR13DataSet dataset) { Console.WriteLine("Running CheckLinkOrder on {0}", dataset.Name); Directory.CreateDirectory(info.OutputDirectory + @"\CheckLinkOrder"); TLSimilarityMatrix oracle = Oracle.Import(dataset.Oracle); foreach (string IRModel in info.IRModels) { WriteSims(ref info, dataset, oracle, IRModel); foreach (string StructuralModel in info.StructuralModels) { WriteSims(ref info, dataset, oracle, IRModel + "_" + StructuralModel); } } }
public override void Compute() { List <CSMR13DataSet> ListOfDatasets = (List <CSMR13DataSet>)Workspace.Load("ListOfDatasets"); CSMR13DataSet CurrentDataset = ListOfDatasets[(int)Workspace.Load("CurrentDataset")]; // import artifacts string[] sourceInfo = CurrentDataset.SourceArtifacts.Split(new char[] { '#' }); string[] targetInfo = CurrentDataset.TargetArtifacts.Split(new char[] { '#' }); Workspace.Store("SourceArtifacts", Artifacts.ImportDirectory(sourceInfo[0], sourceInfo[1])); Workspace.Store("TargetArtifacts", Artifacts.ImportDirectory(targetInfo[0], targetInfo[1])); // import oracle Workspace.Store("Oracle", Oracle.Import(CurrentDataset.Oracle)); // import relationships Workspace.Store("Relationships", Oracle.Import(CurrentDataset.Relationships)); // import stopwords Workspace.Store("Stopwords", Stopwords.Import(CurrentDataset.Stopwords)); }
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(); }