public void TestEmotion1() { SentEmoAnalyzer analyzer = new SentEmoAnalyzer(); analyzer.Initialize(); EmotionState result = analyzer.DoAnalysis("I am happy that you came, Thanks for that."); Assert.IsTrue(result.Joy >= 0.15); Assert.IsTrue(result.Fear <= 0.15); Assert.IsTrue(result.Anger <= 0.15); Assert.IsTrue(result.Disgust <= 0.15); Assert.IsTrue(result.Sadness <= 0.15); Console.WriteLine(result.ToJson()); }
private void button1_Click(object sender, EventArgs e) { TranslationClient client = TranslationClient.CreateFromApiKey(textBox3.Text); Detection languageSpecific = client.DetectLanguage(textBox1.Text); TranslationResult translationResult = client.TranslateText(textBox1.Text, LanguageCodes.English); EmotionState result = analyzer.DoAnalysis(translationResult.TranslatedText); string EmotionJson = result.ToJson(); //if language is detected, then json is translated to source language if (languageSpecific.Confidence > 0.5) { translationResult = client.TranslateText(EmotionJson, languageSpecific.Language); textBox2.Text = translationResult.TranslatedText; } else { textBox2.Text = EmotionJson; } }