示例#1
0
        public static void Analyze(string datasetFolderPath, string methodName, string localizationResultFolderRelativePath, string datasetResultRelativeFilePath, ILog logger = null)
        {
            var datasetMetricResults = new DatasetMetricResult();
            var issues  = new DirectoryInfo(datasetFolderPath).GetDirectories().ToList();
            var total   = issues.Count;
            int counter = 0;

            foreach (var issueDirectoryInfo in issues)
            {
                logger?.Log(++counter + " of " + total);
                var issueFolderPath = issueDirectoryInfo.FullName + @"\";

                var similarityFilePath = $@"{issueFolderPath}{localizationResultFolderRelativePath}{methodName}.txt";
                if (!File.Exists(similarityFilePath))
                {
                    continue;
                }
                var similarityList = File.ReadAllLines(similarityFilePath).Select(x => x.SplitWith(" ")[0]).ToList();

                var relevantList = SerializerHelper.DeserializeFromXmlFile <List <IndexedFile> >(issueFolderPath + "RelevantList.txt").Select(x => x.Index.ToString()).ToList();

                var metricResult = GetMetricNumbers(similarityList, relevantList);
                metricResult.SerializeToXmlFile($@"{issueFolderPath}{localizationResultFolderRelativePath}{methodName}_Result.txt");

                datasetMetricResults.AddMetricResult(metricResult);
            }

            datasetMetricResults.GeneratePercents();
            datasetMetricResults.SerializeToXmlFile($@"{datasetFolderPath}{datasetResultRelativeFilePath}");
        }