public StatisticalAnalysisReport Analyze(TextAnalysisReport report) { return(new StatisticalAnalysisReport { SentenceCount = report.Sentences.Count, WordCount = report.Sentences.Sum(sentence => sentence.Words.Count()) }); }
public DictionaryAnalysisReport Analyze(TextAnalysisReport analysisReport) { var known = new List <Word>(); var unknown = new List <Word>(); var categorizedWords = new List <KeyValuePair <string, IEnumerable <IWordCategory> > >(); foreach (var sentence in analysisReport.Sentences) { foreach (var word in sentence.Words) { word.KnownMatchingCategories = dictionaries.SelectMany(dictionary => dictionary.GetMatchingWords(word)).ToList(); categorizedWords.Add(new KeyValuePair <string, IEnumerable <IWordCategory> >(word.OriginalValue, word.KnownMatchingCategories)); if (word.KnownMatchingCategories.Any()) { known.Add(word); } else { unknown.Add(word); } } } return(new DictionaryAnalysisReport { KnownWords = known, UnknownWords = unknown, WordCategories = categorizedWords, }); }
public SentenceAnalysisReport Analyze(TextAnalysisReport taggingReport) { IEnumerable <IEnumerable <ISentencePart> > analyzedSentences; string errorMessage = string.Empty; try { analyzedSentences = taggingReport.Sentences.Select(sentence => this.AnalyzeSentence(sentence)).ToList(); } catch (InvalidOperationException exception) { analyzedSentences = null; errorMessage = exception.Message; } return(new SentenceAnalysisReport { SentenceParts = analyzedSentences, ErrorMessage = errorMessage, }); }