public async Task <ActionResult <AnalysedTextModel> > TextAnalysis([FromBody] TextAnalizationRequest model) { var response = await _service.TextAnalysis(model); return(Ok(response)); }
public async Task <AnalysedTextModel> TextAnalysis(TextAnalizationRequest model) { var response = new AnalysedTextModel(); var structuredText = await GetStructuredText(model.Text); response.SemanticSize = await SSOTT(structuredText); List <Term> textTerms = null; if (model.IncludeTermsShowing) { textTerms = structuredText.Terms .Distinct(new TermComparer()) .ToList(); response.Text = await IndexTextAsync(structuredText.OriginalText, textTerms); } if (model.IncludeParagraphAnalization) { response.Paragraphs = new List <AnalysedParagraphModel>(); foreach (var paragraph in structuredText.Paragraphs) { var responseParagraph = new AnalysedParagraphModel(); responseParagraph.SemanticSize = await SSOTP(paragraph); if (model.IncludeSentenceAnalization) { responseParagraph.Sentences = new List <AnalysedSentenceModel>(); foreach (var sentence in paragraph.Sentences) { var responseSenetence = new AnalysedSentenceModel(); responseSenetence.SemanticSize = await SSOTS(sentence); if (model.IncludeTermsShowing) { responseSenetence.Text = await IndexTextAsync(sentence.OriginalText, textTerms); } responseParagraph.Sentences.Add(responseSenetence); } } if (model.IncludeTermsShowing) { responseParagraph.Text = await IndexTextAsync(paragraph.OriginalText, textTerms); } response.Paragraphs.Add(responseParagraph); } } response.Terms = structuredText.Terms .Distinct(new TermComparer()) .Select(v => new TermModel(v)) .ToList(); return(response); }