Esempio n. 1
0
        public async Task ProcessText_OneDocument_ReturnOk()
        {
            // Arrange
            var document = "We are one of the finest money transfer company in Nepal. We provide service with a smile.";

            // Act
            var response = await _textAnalytics.ProcessText(document);

            // Assert
            Assert.NotNull(response);
            Assert.True(response.Count == 1);
            Assert.True(document == response.First().Text);
            Assert.False(response.First().IsHeadingCandidate);
        }
        public async Task <ActionResult> Text([FromBody] InputModel inputModel)
        {
            if (inputModel.Document.HasContent())
            {
                // Get settings from cache
                var settingHelper = new SettingHelper(_memoryCache);
                var keys          = $"{SettingKeys.TextAnalyticsEndpoint},{SettingKeys.TextAnalyticsSecret}";
                Dictionary <string, string> settings = settingHelper.GetCachedSettingValuesByKeys(keys);

                // Text analytics
                var textAnalytics = new TextAnalytics(settings[SettingKeys.TextAnalyticsEndpoint], settings[SettingKeys.TextAnalyticsSecret]);
                var response      = await textAnalytics.ProcessText(inputModel.Document);

                return(Ok(response));
            }

            // If it reaches here document has no content return HTTP 400 Bad Request
            return(BadRequest(new { Message = "Document cannot be empty" }));
        }