public string GenerateSummarization() { StringBuilder result = new StringBuilder(Quantifier.Label); result.Append($" players"); if (Qualifier != null) { result.Append(" being/having "); result.Append(Qualifier.Label); result.Append(" "); result.Append(Qualifier.Column); } result.Append(" are/have "); result.Append(Summarizers[0].Label); result.Append(" "); result.Append(Summarizers[0].Column); bool isAnd = LogicalOperationSummarizer == LogicalOperation.And; foreach (var summarizer in Summarizers.Skip(1)) { result.Append($" {(isAnd ? "and" : "or")} "); result.Append(summarizer.Label); result.Append(" "); result.Append(summarizer.Column); } return(result.ToString()); }
/// <summary> /// Initializes a new instance of the <see cref="DefaultTextSummarizer"/> class. /// </summary> /// <param name="summarizers">The summarizers.</param> public DefaultTextSummarizer(IEnumerable <ITextSummarizerLanguage> summarizers) { Summarizers = summarizers.Where(x => x.GetType().Assembly != typeof(DefaultTextSummarizer).Assembly).ToDictionary(x => x.Name); foreach (var Summarizer in summarizers.Where(x => x.GetType().Assembly == typeof(DefaultTextSummarizer).Assembly && !Summarizers.ContainsKey(x.Name))) { Summarizers.Add(Summarizer.Name, Summarizer); } }
private List <LinguisticVariable> GetSummarizersFromComboBoxes() { var listCb = new List <ComboBox> { Summarizer1ComboBox, Summarizer2ComboBox, Summarizer3ComboBox, Summarizer4ComboBox, Summarizer5ComboBox }; var list = new List <LinguisticVariable>(); foreach (var cb in listCb) { if (cb.SelectedItem != null) { list.Add(Summarizers.GetVariableFromString(((ComboBoxItem)cb.SelectedItem).Content .ToString())); } } return(list.Count != 0 ? list : null); }
// Combo Boxes --------------- private void InitializeComboBoxes() { // TypeComboBox TypeComboBox.Items.Add("One-subject summaries"); TypeComboBox.Items.Add("Two-subject summaries"); TypeComboBox.SelectedIndex = 0; // Qualifiers and Summarizers ComboBoxes var listCb = new List <ComboBox> { Qualifier1ComboBox, Qualifier2ComboBox, Qualifier3ComboBox, Qualifier4ComboBox, Qualifier5ComboBox, Summarizer1ComboBox, Summarizer2ComboBox, Summarizer3ComboBox, Summarizer4ComboBox, Summarizer5ComboBox }; foreach (var cb in listCb) { cb.Items.Clear(); } foreach (var s in Summarizers.GetAllVariables()) { foreach (var cb in listCb) { cb.Items.Add(NewItem(s)); } } // P1 and P2 ComboBoxes var subjects = new List <string> { "Attackers", "Midfielders", "Defenders", "Goalkeepers" }; P1ComboBox.Items.Clear(); foreach (var subject in subjects) { P1ComboBox.Items.Add(subject); P2ComboBox.Items.Add(subject); } }
/// <summary> /// Runs the analyzers. /// </summary> /// <returns><c>true</c>, if analyzers was run, <c>false</c> otherwise.</returns> public bool RunAnalyzers() { if (!Analyzers.Any()) { LogManager.Info("No analysis operations configured.", this); return(true); } bool success = false; if (Analyzers?.Count > 0 && InputData?.Keys?.Count >= 1) { var analyzedData = new Dictionary <string, IEnumerable <ICsvWritable> >(); foreach (var analyzerCommand in Analyzers) { // --------------------------------------------------------- // Retrieve analysis operation details // --------------------------------------------------------- var analyzerName = analyzerCommand.Name; var analyzer = AnalyzerManager.GetAnalyzer(analyzerName); if (analyzer == null) { continue; } // Sanity checking ... LogManager.Info($"Running analysis operation:\n\t{analyzer}", this); // --------------------------------------------------------- // Check to see if user requested a summary // --------------------------------------------------------- bool summaryRequested = Summarizers.Contains(analyzerName); // --------------------------------------------------------- // Group input data by original file name // --------------------------------------------------------- var consolidatedInputFiles = Inputs.SelectMany(x => x.InputFiles.Select(y => y.Key)).ToList(); foreach (var origInputFile in consolidatedInputFiles) { var analysisDataByInputFile = new Dictionary <string, IEnumerable <ICsvWritable> >(); var analysisKeysByInputFile = InputData.Keys.Where(x => x.Contains(origInputFile)); foreach (var key in analysisKeysByInputFile) { // ------------------------------------------------- // Perform the actual analysis operation // ------------------------------------------------- if (analyzerCommand.HasParameters && FilterManager.ContainsFilter(Filters, typeof(ThresholdCalibrationFilter))) { var calibData = CalibrationData[origInputFile]; analyzerCommand.Parameters = ThresholdCalibrationFilter.CalibrateParameters (analyzerCommand.Parameters, calibData); } // ------------------------------------------------- // Any required analyzer-specific prep // ------------------------------------------------- if (analyzer is Analyzers.SciKitPrepAnalysis skpAnalyzer) { skpAnalyzer.CurrentInput = key; } else if (analyzer is Analyzers.SciKitEvalAnalysis skeAnalyzer) { skeAnalyzer.CurrentInput = key; } // ------------------------------------------------- var analysisResult = analyzer.Analyze(InputData[key], analyzerCommand.Parameters); analysisDataByInputFile[key] = analysisResult; // ------------------------------------------------- // Dump output to file if necessary // ------------------------------------------------- if (WriteOutputFile) { CsvFileWriter.WriteResultsToFile (new string[] { OutputDirs.Analyzers, analyzerName }, key, analyzer.HeaderCsv, analysisResult); } // ------------------------------------------------- // If requested, summarize file-specific results // ------------------------------------------------- if (summaryRequested) { ISummarizer summarizer = SummarizerManager.GetSummarizer(analyzerName); var summarizedValues = summarizer.Summarize(analysisDataByInputFile); if (WriteOutputFile) { CsvFileWriter.WriteSummaryToFile (new string[] { OutputDirs.Summarizers, analyzerName }, $"{origInputFile}{Constants.BAT.DEFAULT_INPUT_FILE_EXT}", summarizer.HeaderCsv, summarizedValues, summarizer.FooterCsv, summarizer.FooterValues); } } } // consolidate the results by input file var inputFileResults = analyzer.ConsolidateData(analysisDataByInputFile); if (analyzedData.ContainsKey(origInputFile)) { analyzedData[origInputFile] = inputFileResults; } else { analyzedData.Add(origInputFile, inputFileResults); } } // ----------------------------------------------------- // If requested, aggregate all file-specific summaries // into one high level file in root summarizer directory // ----------------------------------------------------- if (summaryRequested) { ISummarizer summarizer = SummarizerManager.GetSummarizer(analyzerName); var summarizedValues = summarizer.Summarize(analyzedData); if (WriteOutputFile) { CsvFileWriter.WriteSummaryToFile (new string[] { OutputDirs.Summarizers }, $"{analyzerName}Aggregate{Constants.BAT.DEFAULT_INPUT_FILE_EXT}", summarizer.HeaderCsv, summarizedValues, summarizer.FooterCsv, summarizer.FooterValues); } } success = true; } // use different collection to maintain integrity of original input data AnalysisData = analyzedData; } else { LogManager.Error("No input data to run analyzers on.", this); } return(success); }