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 analyzer = new TextAnalyzer(); DoAndPrintTime(() => { analyzer.AnalyzeFile(filePath); analyzer.RemoveLowFrequency((int)(analyzer.Total * MinRate)); analyzer.Save(outFilePath); }, $"Analyze: {filePath}"); } }
public static void QueryStatistics(string filePath) { if (!File.Exists(filePath)) { Console.WriteLine("File not exist."); return; } var stat = new TextAnalyzer(filePath); while (true) { Console.Write("Statistics > "); var input = Console.ReadLine().Trim(); int count = stat.GetStringCount(input); Console.WriteLine(count); } }
// Abstract Method public virtual void FromAnalyzer(TextAnalyzer analyzer) { SourceName = analyzer.SourceName; }
public override void FromAnalyzer(TextAnalyzer stat) { throw new InvalidOperationException(); }