/// <summary>
        /// Runs the content analyzis part of the summarizing algorithm
        /// </summary>
        /// <param name="parsedDocument"></param>
        /// <param name="contentAnalyzer"></param>
        /// <returns></returns>
        public AnalyzedDocument AnalyzeParsedContent(ParsedDocument parsedDocument, IContentAnalyzer contentAnalyzer)
        {
            if (parsedDocument == null)
            {
                throw new ArgumentNullException(nameof(parsedDocument));
            }
            if (contentAnalyzer == null)
            {
                throw new ArgumentNullException(nameof(contentAnalyzer));
            }

            var importantTextUnits = contentAnalyzer.GetImportantTextUnits(parsedDocument.Sentences);
            if (importantTextUnits == null)
            {
                throw new InvalidOperationException(
                    $"{contentAnalyzer.GetType().FullName}.GetImportantTextUnits must not return null");
            }
            var scoredSentences = contentAnalyzer.ScoreSentences(parsedDocument.Sentences, importantTextUnits);
            if (scoredSentences == null)
            {
                throw new InvalidOperationException(
                    $"{contentAnalyzer.GetType().FullName}.ScoreSentences must not return null");
            }

            return new AnalyzedDocument() { ScoredTextUnits = importantTextUnits.OrderByDescending(tus => tus.Score).ToList(), ScoredSentences = scoredSentences.OrderByDescending(ss => ss.Score).ToList() };
        }
        /// <summary>
        /// Runs the content analysis part of the summarizing algorithm
        /// </summary>
        /// <param name="parsedDocument"></param>
        /// <param name="contentAnalyzer"></param>
        /// <returns></returns>
        public AnalyzedDocument AnalyzeParsedContent(ParsedDocument parsedDocument, IContentAnalyzer contentAnalyzer)
        {
            if (parsedDocument == null)
            {
                throw new ArgumentNullException(nameof(parsedDocument));
            }
            if (contentAnalyzer == null)
            {
                throw new ArgumentNullException(nameof(contentAnalyzer));
            }

            List <TextUnitScore> importantTextUnits = contentAnalyzer.GetImportantTextUnits(parsedDocument.Sentences);

            if (importantTextUnits == null)
            {
                throw new InvalidOperationException($"{contentAnalyzer.GetType().FullName}.GetImportantTextUnits must not return null");
            }
            List <SentenceScore> scoredSentences = contentAnalyzer.ScoreSentences(parsedDocument.Sentences, importantTextUnits);

            if (scoredSentences == null)
            {
                throw new InvalidOperationException($"{contentAnalyzer.GetType().FullName}.ScoreSentences must not return null");
            }

            return(new AnalyzedDocument {
                ScoredTextUnits = importantTextUnits.OrderByDescending(tus => tus.Score).ToList(), ScoredSentences = scoredSentences.OrderByDescending(ss => ss.Score).ToList()
            });
        }
        /// <summary>
        /// Runs the content analyzis part of the summarizing algorithm
        /// </summary>
        /// <param name="parsedDocument"></param>
        /// <param name="contentAnalyzer"></param>
        /// <returns></returns>
        public AnalyzedDocument AnalyzeParsedContent(ParsedDocument parsedDocument, IContentAnalyzer contentAnalyzer)
        {
            if (parsedDocument == null)
            {
                throw new ArgumentNullException("parsedDocument");
            }
            if (contentAnalyzer == null)
            {
                throw new ArgumentNullException("contentAnalyzer");
            }

            var importantTextUnits = contentAnalyzer.GetImportantTextUnits(parsedDocument.Sentences);

            if (importantTextUnits == null)
            {
                throw new InvalidOperationException(string.Format("{0}.GetImportantTextUnits must not return null", contentAnalyzer.GetType().FullName));
            }
            var scoredSentences = contentAnalyzer.ScoreSentences(parsedDocument.Sentences, importantTextUnits);

            if (scoredSentences == null)
            {
                throw new InvalidOperationException(string.Format("{0}.ScoreSentences must not return null", contentAnalyzer.GetType().FullName));
            }

            return(new AnalyzedDocument()
            {
                ScoredTextUnits = importantTextUnits.OrderByDescending(tus => tus.Score).ToList(), ScoredSentences = scoredSentences.OrderByDescending(ss => ss.Score).ToList()
            });
        }
 public FakeGoogleProvider(
     FakeGoogleClient fakeClient,
     ILogger <StorageProvider> logger,
     IFeatureCollection <IStorageProvider> features = null,
     IContentAnalyzer contentAnalyzer = null,
     GoogleCloudStorageOptions <FakeGoogleProvider> options = null) : base(logger, features, contentAnalyzer, options)
 {
     _fakeClient = fakeClient;
 }
Exemple #5
0
        public StorageProvider(
            ILogger <StorageProvider> logger,
            IFeatureCollection <IStorageProvider> features = null,
            IContentAnalyzer contentAnalyzer  = null,
            GoogleCloudStorageOptions options = null)
        {
            if (features == null)
            {
                features = new FeatureCollectionBuilder().Build <IStorageProvider>();
            }
            var googleFeatures = new FeatureCollectionBuilder();

            googleFeatures.AddFeature <ICacheControlFeature>(new CacheControlFeature());
            googleFeatures.AddFeature <ICreateByPathFeature>(new CreateByPathFeature());
            googleFeatures.AddFeature <IRecordCopyFeature>(new RecordCopyFeature());
            googleFeatures.AddFeature <ILoggerFeature>(new LoggerFeature());
            Features        = new CompositeFeatureCollection(features, googleFeatures.Build());
            Logger          = logger ?? throw new ArgumentNullException(nameof(logger));
            ContentAnalyzer = contentAnalyzer;
            Options         = options ?? GoogleCloudStorageOptions.Default;
        }
 public void throws_if_null_arguments_are_passed(ParsedDocument parsedDocument,
     IContentAnalyzer contentAnalyzer)
 {
     Assert.Throws<ArgumentNullException>(
         () => { Target.AnalyzeParsedContent(parsedDocument, contentAnalyzer); });
 }
Exemple #7
0
 public void throws_if_null_arguments_are_passed(ParsedDocument parsedDocument, IContentAnalyzer contentAnalyzer)
 {
     Assert.That(() => Target.AnalyzeParsedContent(parsedDocument, contentAnalyzer), Throws.TypeOf <ArgumentNullException>());
 }
 public void throws_if_null_arguments_are_passed(ParsedDocument parsedDocument, IContentAnalyzer contentAnalyzer)
 {
     Target.AnalyzeParsedContent(parsedDocument, contentAnalyzer);
 }
Exemple #9
0
 public void throws_if_null_arguments_are_passed(ParsedDocument parsedDocument, IContentAnalyzer contentAnalyzer)
 {
     Target.AnalyzeParsedContent(parsedDocument, contentAnalyzer);
 }
Exemple #10
0
 protected StorageProvider(IFeatureCollection <IStorageProvider> features, ILogger <StorageProvider> logger, IContentAnalyzer contentAnalyzer)
 {
     Features        = features ?? throw new ArgumentNullException(nameof(features));
     ContentAnalyzer = contentAnalyzer;
     Logger          = logger ?? throw new ArgumentNullException(nameof(logger));
 }
Exemple #11
0
 public LinuxStorageProvider(IFeatureCollection <IStorageProvider> features, ILogger <LinuxStorageProvider> logger, IContentAnalyzer contentAnalyzer = null, FileSystemStorageOptions options = null)
     : base(features, logger, contentAnalyzer)
 {
     _options = options ?? new FileSystemStorageOptions {
         RootPath = "/"
     };
     _linuxStorageRoot = new LinuxStorageRoot(this, _options.RootPath);
 }