/// <summary> /// Default constructor: Init components, set context. /// Optionally set dummy data. /// </summary> public TextAnalyticsView() { InitializeComponent(); TextAnalyticsApp = new TextAnalyticsManager(); DataContext = TextAnalyticsApp; TextAnalyticsApp.TextToAnalyse = "Input some text here..."; }
/// <summary> /// Main Program. /// </summary> /// <param name="args"></param> static void Main(string[] args) { PrintLicense(); EmotionApp = new EmotionManager(); TextAnalyticsApp = new TextAnalyticsManager(); // Basic testing/using interface for the console // Wait for correct user input // - choice of service (Emotion, Text Analytics, Quit) // --- if Emotion, ask image path // --- Check image exists // --- if exists, start Emotion service // --- else ask image again // --- if nothing entered go back to choice of service // - // --- if Text Analytics, ask to input text // --- start Text analytics service on Enter // --- if no text go back to choice of service // - // - Service provides results // - after that, the prompt stays in the same service // - user can enter another content // - if nothing entered, back to choice of service while (SessionIsNotOver) { DebugWarning("Enter session loop"); // Set the user choice if none is actually set. // This allows the main loop to flow at the end of a service // until the user explicitely chose to change service if (UserChoice == UserChoices.None) { AskInputFromUser(); } // Act according to the user's choice switch (UserChoice) { case UserChoices.EndSession: EndSession(); break; case UserChoices.StartEmotionAPI: AskImagePathFromUser(); break; case UserChoices.StartTextAnalyticsAPI: AskTextFromUser(); break; case UserChoices.Testing: TestProgram(); break; default: break; } // loop } // The program ends. }
/// <summary> /// /// </summary> /// <param name="model"></param> /// <returns></returns> private async Task ExecuteAnalysis(AnalysisModel model) { var tokenResult = await CotohaApiManager.GetAccessTokenAsync(); if (tokenResult.StatusCode == HttpStatusCode.Created) { model.KeywordResult = await CotohaApiManager.ExtractionKeywordsAsync(new CotohaAPI.Models.KeyWordRequest() { Document = model.Presenter.SpeachText, Type = "kuzure", DoSegment = true, MaxKeywordNum = 10 }); model.KeyPhraseExtractResult = await TextAnalyticsManager.ExecuteJapaneseKeyPhraseExtractAsync(string.Join("。", model.Presenter.SpeachText)); } }