/// <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() }); }
/// <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(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() }; }