示例#1
0
        public IActionResult Analyze(AnalyzeViewModel model)
        {
            if (model.UseMinWordLen && model.MinWordLen < 1)
            {
                return(BadRequest("مقدار حداقل تعداد حروف هر کلمه باید بیش از ۱ باشد."));
            }

            var longestWords = _analyzeService.LongestWordsAnalyzer(model.Text, new AnalyzeConfigDto()
            {
                UseMinWordLen       = model.UseMinWordLen,
                MinWordLen          = model.MinWordLen,
                UseStopwords        = model.UseStopwords,
                StopwordId          = model.StopwordId,
                ParseConnectedWords = model.ParseConnectedWords
            });
            var mostRepetitiveWords = _analyzeService.MostRepetitiveWordsAnalyzer(model.Text, new AnalyzeConfigDto()
            {
                UseMinWordLen       = model.UseMinWordLen,
                MinWordLen          = model.MinWordLen,
                UseStopwords        = model.UseStopwords,
                StopwordId          = model.StopwordId,
                ParseConnectedWords = model.ParseConnectedWords
            });
            var textWordCount = _analyzeService.CountTextWordsAnalyzer(model.Text, new AnalyzeConfigDto()
            {
                UseMinWordLen       = model.UseMinWordLen,
                MinWordLen          = model.MinWordLen,
                UseStopwords        = model.UseStopwords,
                StopwordId          = model.StopwordId,
                ParseConnectedWords = model.ParseConnectedWords
            });
            var distinctTextWordCount = _analyzeService.CountTextDistinctWordsAnalyzer(model.Text, new AnalyzeConfigDto()
            {
                UseMinWordLen       = model.UseMinWordLen,
                MinWordLen          = model.MinWordLen,
                UseStopwords        = model.UseStopwords,
                StopwordId          = model.StopwordId,
                ParseConnectedWords = model.ParseConnectedWords
            });

            return(Ok(new
            {
                longestWords,
                mostRepetitiveWords,
                textWordCount,
                distinctTextWordCount
            }));
        }