public static async Task Run([ServiceBusTrigger("myqueue", Connection = "ServiceBusConnectionString")] string htmlText, ILogger log,
                                     [Inject] ILUISService ILUISService,
                                     [Inject] IQnAService IQnAService,
                                     [Inject] ITextAnalyticsService ITextAnalyticsService,
                                     [Inject] IQueueService IQueueService)
        {
            var method = "Main";

            log.LogInformation(string.Format("{0} - {1}", method, "IN"));

            if (string.IsNullOrWhiteSpace(htmlText))
            {
                throw new ArgumentNullException("You need to provide a text to test!");
            }
            var sanitizedText = HelperMethods.HtmlToPlainText(htmlText);

            log.LogInformation(string.Format("{0} - {1}", method, "Extracting information from LUIS."));
            var result = await ILUISService.ExtractEntitiesFromLUIS(sanitizedText);

            if (result.TopScoringIntent.Intent.Equals("FAQ"))
            {
                log.LogInformation(string.Format("{0} - {1}", method, "Getting FAQs Answer."));
                var response = IQnAService.CheckQnAMakerForResponse(sanitizedText);
                IQueueService.InsertAnswerIntoCRM(response);
            }
            else
            {
                log.LogInformation(string.Format("{0} - {1}", method, "Getting Keywords and Sentiment."));
                var response = ITextAnalyticsService.ExtractKeywordsAndSentimentFromTextAnalytics(sanitizedText);
                IQueueService.InsertKeywordAndSentimentoIntoCRM(response);
            }
        }
Exemple #2
0
        public OCRViewModel(ISettingsService settingsService = null)
        {
            this.settingsService = settingsService ?? DependencyService.Get <ISettingsService>();

            /*
             * var handler = new HttpClientHandler
             * {
             *  UseProxy = true,
             *  Proxy = new WebProxy("http://localhost:8888", false) // Or whatever Charles is set up as
             * };
             * var client = new HttpClient(handler)
             * {
             *  BaseAddress = new Uri(this.settingsService.TextRecognitionEndPoint)
             * };*/

            this.ocrService        = RestService.For <IOCRTextService>(this.settingsService.TextRecognitionEndPoint);
            this.translatorService = RestService.For <ITranslatorService>(this.settingsService.TranslatorEndPoint);
            this.luisService       = RestService.For <ILUISService>(this.settingsService.LuisEndPoint);
            this.ToggleTranslateVisibilityCommand = new Command(this.OnToggleTranslateVisibility);

            this.TranslationInterfaceVisibility = true;
        }