public SampleController(INlpRepository <Model> repo, IModelRepository <Model> modelrepo, ISummarizer summarizer, IStemmer stemmer) { _repo = repo ?? throw new NlpException(HttpStatusCode.InternalServerError, nameof(repo)); _modelrepo = modelrepo ?? throw new NlpException(HttpStatusCode.InternalServerError, nameof(modelrepo)); _summarizer = summarizer ?? throw new NlpException(HttpStatusCode.InternalServerError, nameof(summarizer)); _stemmer = stemmer ?? throw new NlpException(HttpStatusCode.InternalServerError, nameof(stemmer)); }
public TextMiningRepository(ILogger <TextMiningRepository <T> > logger, IStemmer stemmer, ISummarizer summarizer, Models <T> models) { _logger = logger ?? throw new NlpException(HttpStatusCode.InternalServerError, nameof(logger)); _stemmer = stemmer ?? throw new NlpException(HttpStatusCode.InternalServerError, nameof(stemmer)); _summarizer = summarizer ?? throw new NlpException(HttpStatusCode.InternalServerError, nameof(summarizer)); _models = models ?? throw new NlpException(HttpStatusCode.InternalServerError, nameof(models)); }
public InMemoryDataRepositoryService() { var config = Catalog.Factory.Resolve <IConfig>(SpecialFactoryContexts.Routed); _summaryMetadataSource = config.Get <IMetadataProvider <TSummaryType, TSummaryMetadataType> >( DataRepositoryServiceLocalConfig.SummaryMetadataProvider); _itemMetadataSource = config.Get <IMetadataProvider <TDataType, TItemMetadataType> >( DataRepositoryServiceLocalConfig.ItemMetadataProvider); _summarizer = config.Get <ISummarizer <TDataType, TSummaryType> >(DataRepositoryServiceLocalConfig.Summarizer); if (config.SettingExists(DataRepositoryServiceLocalConfig.ContextFilter)) { _contextFilter = config.Get <IContextFilter>(DataRepositoryServiceLocalConfig.ContextFilter); } IEnumerable <TDataType> initialData = null; if (config.SettingExists(InMemoryDataRepositoryServiceLocalConfig.OptionalInitialData)) { initialData = config.Get <IEnumerable <TDataType> >(InMemoryDataRepositoryServiceLocalConfig.OptionalInitialData); } if (null != initialData) { initialData.ForEach(d => _data.TryAdd(DataDocument.GetDocumentId(d), d)); } }
public DataController(JsonConverter[] converters, ISummarizer repository, ISitesRepository sitesRepository, IErrorController errorController, IUsersRepository userRepository) : base(errorController) { m_Converters = converters; m_TimeSeriesRepository = repository; m_SiteRepository = sitesRepository; m_userRepository = userRepository; }
/// <summary> /// Initializes a new instance of the <see cref="StreamBinding"/> class. /// </summary> /// <param name="source">An existing stream binding to clone.</param> /// <param name="summarizerType">The type of the stream summarizer, null if there is none.</param> /// <param name="summarizerArgs">The arguments used when constructing the stream summarizer, null if ther is none.</param> public StreamBinding(StreamBinding source, Type summarizerType, object[] summarizerArgs) : this(source.StreamName, source.PartitionName, source.StoreName, source.StorePath, source.SimpleReaderType, source.StreamAdapterType, summarizerType, summarizerArgs) { this.streamAdapter = source.streamAdapter; // Do not copy this over since the type or args may have changed this.summarizer = null; }
public DocumentRepositoryService() { var config = Catalog.Factory.Resolve <IConfig>(SpecialFactoryContexts.Routed); _summaryMetadataSource = config.Get <IMetadataProvider <TSummaryType, TSummaryMetadataType> >( DataRepositoryServiceLocalConfig.SummaryMetadataProvider); _itemMetadataSource = config.Get <IMetadataProvider <TDataType, TItemMetadataType> >( DataRepositoryServiceLocalConfig.ItemMetadataProvider); _summarizer = config.Get <ISummarizer <TDataType, TSummaryType> >(DataRepositoryServiceLocalConfig.Summarizer); _updateAssignment = config.Get <Action <TDataType, TDataType> >(DataRepositoryServiceLocalConfig.UpdateAssignment); if (config.SettingExists(DataRepositoryServiceLocalConfig.ContextFilter)) { _contextFilter = config.Get <IContextFilter>(DataRepositoryServiceLocalConfig.ContextFilter); } }
/// <summary> /// Initializes a new instance of the <see cref="StreamSource"/> class. /// </summary> /// <param name="partitionViewModel">The partition that is the stream's data source.</param> /// <param name="streamReaderType">The type of stream reader that should be used to read data from the store.</param> /// <param name="streamName">The name of the stream.</param> /// <param name="streamMetadata">The metadata for the stream.</param> /// <param name="streamAdapter">The stream adapter to use when reading stream data.</param> /// <param name="summarizer">The summarizer to use when reading the stream.</param> public StreamSource( PartitionViewModel partitionViewModel, Type streamReaderType, string streamName, IStreamMetadata streamMetadata, IStreamAdapter streamAdapter, ISummarizer summarizer) { this.StoreName = partitionViewModel.StoreName; this.StorePath = partitionViewModel.StorePath; this.StreamReaderType = streamReaderType; this.StreamName = streamName; this.StreamMetadata = streamMetadata; this.StreamAdapter = streamAdapter; this.Summarizer = summarizer; this.IsLive = partitionViewModel.IsLivePartition; partitionViewModel.PropertyChanged += this.PartitionPropertyChanged; }
/// <summary> /// Initializes a new instance of the <see cref="StreamSummary{TSrc, TDest}"/> class. /// </summary> /// <param name="streamBinding">Stream binding indicating which stream to summarize.</param> /// <param name="interval">The time interval over which summary <see cref="IntervalData"/> values are calculated.</param> /// <param name="maxCacheSize">The maximum amount of data to cache before purging older summarized data.</param> public StreamSummary(StreamBinding streamBinding, TimeSpan interval, uint maxCacheSize) { this.streamBinding = streamBinding; this.interval = interval; this.maxCacheSize = maxCacheSize; this.summaryDataBuffer = new List <List <IntervalData <TDest> > >(); this.keySelector = s => Summarizer <TSrc, TDest> .GetIntervalStartTime(s.OriginatingTime, interval); this.itemComparer = Comparer <IntervalData <TDest> > .Create((r1, r2) => this.keySelector(r1).CompareTo(this.keySelector(r2))); this.summaryCache = new ObservableKeyedCache <DateTime, IntervalData <TDest> >(null, this.itemComparer, this.keySelector); this.activeStreamViews = new Dictionary <Tuple <DateTime, DateTime, uint, Func <DateTime, DateTime> >, ObservableKeyedCache <DateTime, Message <TSrc> > .ObservableKeyedView>(); this.cachedSummaryViews = new Dictionary <Tuple <DateTime, DateTime, uint, Func <DateTime, DateTime> >, ObservableKeyedCache <DateTime, IntervalData <TDest> > .ObservableKeyedView>(); // Cache the summarizer (cast to the correct type) to call its methods later on without dynamic binding this.summarizer = this.StreamBinding.Summarizer as ISummarizer <TSrc, TDest>; }
/// <summary> /// Initializes a new instance of the <see cref="StreamSource"/> class. /// </summary> /// <param name="partitionViewModel">The partition that is the stream's data source.</param> /// <param name="streamReaderType">The type of stream reader that should be used to read data from the store.</param> /// <param name="streamName">The name of the stream.</param> /// <param name="streamMetadata">The metadata for the stream.</param> /// <param name="streamAdapter">The stream adapter to use when reading stream data.</param> /// <param name="summarizer">The summarizer to use when reading the stream.</param> /// <param name="allocator">The allocator to use when reading data.</param> /// <param name="deallocator">The deallocator to use when reading data.</param> public StreamSource( PartitionViewModel partitionViewModel, Type streamReaderType, string streamName, IStreamMetadata streamMetadata, IStreamAdapter streamAdapter, ISummarizer summarizer, Func <dynamic> allocator, Action <dynamic> deallocator) { this.StoreName = partitionViewModel.StoreName; this.StorePath = partitionViewModel.StorePath; this.StreamReaderType = streamReaderType; this.StreamName = streamName; this.StreamMetadata = streamMetadata; this.StreamAdapter = streamAdapter; this.Summarizer = summarizer; this.IsLive = partitionViewModel.IsLivePartition; this.Allocator = allocator; this.Deallocator = deallocator; partitionViewModel.PropertyChanged += this.OnPartitionViewModelPropertyChanged; }
public SummarizerTests() { _summarizer = new Helper <ISummarizer>().GetService(); }
public void Setup() { _summarizer = new Summarizer(); }
/// <summary> /// Initializes a new instance of the <see cref="StreamBinding"/> class. /// </summary> /// <param name="source">An existing stream binding to clone.</param> /// <param name="storeName">The store name.</param> /// <param name="storePath">The store path.</param> public StreamBinding(StreamBinding source, string storeName, string storePath) : this(source.StreamName, source.PartitionName, storeName, storePath, source.SimpleReaderType, source.StreamAdapterType, source.SummarizerType, source.SummarizerArgs) { this.streamAdapter = source.streamAdapter; this.summarizer = source.summarizer; }
public bool CreateSummerizer() { _mysummarizer = _mySummarizerFactory.Create(_summarizerName); return (_mysummarizer != null) ? true : false; }
/// <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); }