コード例 #1
0
        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;
        }
コード例 #2
0
 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);
         }
     }
 }
コード例 #3
0
 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();
 }