예제 #1
0
 public static void RemoveLowFrequency(string statPath)
 {
     DoAndPrintTime(() =>
     {
         var statistician = new TextStatistician();
         statistician.Load(statPath);
         statistician.RemoveLowFrequency((int)(statistician.Total * MinRate));
         statistician.Save(statPath);
     }, $"Remove low frequency ({MinRate}): {statPath}");
 }
예제 #2
0
        public static void MergeFiles(IEnumerable <string> filePaths, string outFilePath)
        {
            var stat = new TextStatistician();

            foreach (var filePath in filePaths)
            {
                DoAndPrintTime(() => stat.MergeFrom(new TextStatistician(filePath)),
                               $"Merge: {filePath}");
            }
            DoAndPrintTime(() => stat.RemoveLowFrequency((int)(stat.Total * MinRate)), $"Remove low frequency ({MinRate})");
            DoAndPrintTime(() => stat.Save(outFilePath), $"Save to {outFilePath}");
        }
예제 #3
0
        public static void AnalyzeFiles(IEnumerable <string> filePaths, string statPath, bool append = false)
        {
            var statistician = new TextStatistician();

            if (append)
            {
                statistician.Load(statPath);
            }
            AnalyzeFiles(statistician, filePaths);
            statistician.RemoveLowFrequency((int)(statistician.Total * MinRate));
            DoAndPrintTime(() => statistician.Save(statPath), $"Writing to file: {statPath}");
        }
예제 #4
0
 public static void AnalyzeFilesSeparately(IEnumerable <string> filePaths, string outputDir = null)
 {
     foreach (var filePath in filePaths)
     {
         var fileInfo     = new FileInfo(filePath);
         var outFilePath  = $"{outputDir ?? fileInfo.DirectoryName}/{fileInfo.Name}_stat.csv";
         var statistician = new TextStatistician();
         DoAndPrintTime(() =>
         {
             statistician.AnalyzeFile(filePath);
             statistician.RemoveLowFrequency((int)(statistician.Total * MinRate));
             statistician.Save(outFilePath);
         }, $"Analyze: {filePath}");
     }
 }