private void Update() { if (!string.IsNullOrEmpty(TextInput)) { int nRet = Engine.PrepareText(_inputText); //returns 0 if less than 1000 words Console.WriteLine(nRet); if (nRet == 0 || nRet == 6) //not sure what 0 or 6 means but that's what Salience set the returns for non-error as { SalienceSentiment mySentiment = Engine.GetDocumentSentiment(true, String.Empty); resetList(); DocumentSentiment = mySentiment.fScore * 100; DocScore = (int)DocumentSentiment; foreach (var a in mySentiment.Phrases.ToArray()) { S_Phrase p = new S_Phrase { sp_score = a.fScore, sp_phrase = a.Phrase.sText }; PhraseList.Add(p); } foreach (var b in mySentiment.ModelSentiment.ToArray()) { S_ModelSentiment m = new S_ModelSentiment { ms_name = b.sName, ms_best = b.nBest, ms_positive = b.fPositive, ms_mixed = b.fMixed, ms_negative = b.fNegative, ms_neutral = b.fNeutral }; ModelSentimentList.Add(m); } List <KeyValuePair <string, int> > MyValue = new List <KeyValuePair <string, int> >(); MyValue.Add(new KeyValuePair <string, int>("Positive", (int)(ModelSentimentList[0].ms_positive * 100))); MyValue.Add(new KeyValuePair <string, int>("Negative", (int)(ModelSentimentList[0].ms_negative * 100))); MyValue.Add(new KeyValuePair <string, int>("Mixed", (int)(ModelSentimentList[0].ms_mixed * 100))); MyValue.Add(new KeyValuePair <string, int>("Neutral", (int)(ModelSentimentList[0].ms_neutral * 100))); PieChartItems = MyValue; /* * foreach (var c in mySentiment.Emotions.ToArray()) * { * S_Emotion e = new S_Emotion * { * e_topic = c.sTopic, * e_hit = c.nHits, * e_score = c.fScore, * s_summary = c.sSummary * }; * EmotionList.Add(e); * } */ } } }
private void resetList() { EmotionList.Clear(); PhraseList.Clear(); ModelSentimentList.Clear(); }