/// <summary> /// IMPORTANT: The indices passed in the dictionary "oneMinuteOfIndices" must be normalised. /// </summary> /// <param name="templates">The templates read from json file.</param> /// <param name="templatesAsDictionary">The numerical part of each template.</param> /// <param name="oneMinuteOfIndices">The normalised values of the indices derived from one minute of recording.</param> /// <param name="minuteId">The minute ID, i.e. its temporal position.</param> /// <returns>A single instance of a DescriptionResult.</returns> public static DescriptionResult AnalyzeOneMinute( FunctionalTemplate[] templates, Dictionary <string, Dictionary <string, double[]> > templatesAsDictionary, Dictionary <string, double[]> oneMinuteOfIndices, int minuteId) { // initialise where the results will be stored. var descriptionResult = new DescriptionResult(minuteId); // now subject the indices to various content searches foreach (var template in templates) { var algorithmType = template.Manifest.FeatureExtractionAlgorithm; var templateIndices = templatesAsDictionary[template.Manifest.Name]; double score; // Following line used where want to return a set of random scores for testing reasons. //var score = new RandomNumber(DateTime.Now.Millisecond); switch (algorithmType) { case 1: score = ContentAlgorithms.GetFullBandContent1(oneMinuteOfIndices, template.Manifest, templateIndices); break; case 2: score = ContentAlgorithms.GetBroadbandContent1(oneMinuteOfIndices, template.Manifest, templateIndices); break; case 3: score = ContentAlgorithms.GetNarrowBandContent1(oneMinuteOfIndices, template.Manifest, templateIndices); break; default: LoggedConsole.WriteWarnLine("Algorithm " + algorithmType + " does not exist."); score = 0.0; break; } var result = new KeyValuePair <string, double>(template.Manifest.Description, score); descriptionResult.AddDescription(result); } return(descriptionResult); }
/// <summary> /// This method calculates new template based on passed manifest. /// </summary> public static Dictionary <string, double[]> CreateTemplateDefinition(TemplateManifest templateManifest) { // Get the template provenance. Assume array contains only one element. var provenanceArray = templateManifest.Provenance; var provenance = provenanceArray[0]; var sourceDirectory = provenance.Directory; var baseName = provenance.Basename; // Read all indices from the complete recording. The path variable is a partial path requiring to be appended. var path = Path.Combine(sourceDirectory, baseName + ContentSignatures.AnalysisString); var dictionaryOfIndices = DataProcessing.ReadIndexMatrices(path); var algorithmType = templateManifest.FeatureExtractionAlgorithm; Dictionary <string, double[]> newTemplateDefinition; switch (algorithmType) { case 1: newTemplateDefinition = ContentAlgorithms.CreateFullBandTemplate1(templateManifest, dictionaryOfIndices); break; case 2: newTemplateDefinition = ContentAlgorithms.CreateBroadbandTemplate1(templateManifest, dictionaryOfIndices); break; case 3: newTemplateDefinition = ContentAlgorithms.CreateNarrowBandTemplate1(templateManifest, dictionaryOfIndices); break; default: //LoggedConsole.WriteWarnLine("Algorithm " + algorithmType + " does not exist."); newTemplateDefinition = null; break; } return(newTemplateDefinition); }