示例#1
0
        private void ToneSetterUpload(string text)
        {
            try
            {
                ToneAnalyzerJSON obj = new ToneAnalyzerJSON();
                ToneAnalyser.Parse(obj, text);

                int[] a = { 0, 0, 0, 0, 0, 0 };
                foreach (var item in obj.sentences_tone)
                {
                    foreach (var i in item.tones)
                    {
                        if (i.tone_id == "joy")
                        {
                            a[0] += (int)(i.score * 100);
                        }
                        else if (i.tone_id == "anger")
                        {
                            a[1] += (int)(i.score * 100);
                        }
                        else if (i.tone_id == "sadness")
                        {
                            a[2] += (int)(i.score * 100);
                        }
                        else if (i.tone_id == "disgust")
                        {
                            a[3] += (int)(i.score * 100);
                        }
                        else if (i.tone_id == "fear")
                        {
                            a[4] += (int)(i.score * 100);
                        }
                        else if (i.tone_id == "confident")
                        {
                            a[5] += (int)(i.score * 100);
                        }
                    }
                }

                for (int i = 0; i < 6; i++)
                {
                    a[i] = a[i] / obj.sentences_tone.Length;
                }

                label_happy.Text      = a[0].ToString() + " %";
                label_angry.Text      = a[1].ToString() + " %";
                label_sad.Text        = a[2].ToString() + " %";
                label_disgust.Text    = a[3].ToString() + " %";
                label_fear.Text       = a[4].ToString() + " %";
                label_confidence.Text = a[5].ToString() + " %";

                Form1.outputText = text;
            }
            catch { }
        }
示例#2
0
        private void ToneSetterRecord(string text)
        {
            try
            {
                ToneAnalyzerJSON obj = new ToneAnalyzerJSON();
                ToneAnalyser.Parse(obj, text);
                for (int i = 0; i < obj.document_tone.tones.Length; i++)
                {
                    if (obj.document_tone.tones[i].tone_id == "sadness")
                    {
                        label_sad.Text = ((int)(obj.document_tone.tones[i].score * 100)).ToString() + " %";
                    }
                    else if (obj.document_tone.tones[i].tone_id == "joy")
                    {
                        label_happy.Text = ((int)(obj.document_tone.tones[i].score * 100)).ToString() + " %";
                    }
                    else if (obj.document_tone.tones[i].tone_id == "fear")
                    {
                        label_fear.Text = ((int)(obj.document_tone.tones[i].score * 100)).ToString() + " %";
                    }
                    else if (obj.document_tone.tones[i].tone_id == "disgust")
                    {
                        label_disgust.Text = ((int)(obj.document_tone.tones[i].score * 100)).ToString() + " %";
                    }
                    else if (obj.document_tone.tones[i].tone_id == "anger")
                    {
                        label_angry.Text = ((int)(obj.document_tone.tones[i].score * 100)).ToString() + " %";
                    }

                    else if (obj.document_tone.tones[i].tone_id == "confident")
                    {
                        label_sad.Text = ((int)(obj.document_tone.tones[i].score * 100)).ToString() + " %";
                    }
                }
                Form1.outputText = text;
            }
            catch { }
        }
示例#3
0
 public static void Parse(ToneAnalyzerJSON JSON, string inputText)
 {
     Newtonsoft.Json.JsonConvert.PopulateObject(getResponse(inputText), JSON);
 }