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); * } */ } } }
public void ProcessExecute() { Themes.Clear(); int nRet = Engine.PrepareText(TextToAnalyse); if (nRet == 0) { // Get themes List <SalienceTheme> myThemes = Engine.GetDocumentThemes(String.Empty); foreach (SalienceTheme aTheme in myThemes) { Themes.Add(new Theme(aTheme.sNormalizedTheme, aTheme.fScore, aTheme.nThemeType, aTheme.fSentiment, aTheme.nEvidence)); } // Get named entities List <SalienceEntity> myEntities = Engine.GetNamedEntities(String.Empty); foreach (SalienceEntity anEntity in myEntities) { NamedEntities.Add(new NamedEntity(anEntity.sNormalizedForm, anEntity.sType, anEntity.fSentimentScore, anEntity.nEvidence, anEntity.nCount)); } // Get summary SalienceSummary mySummary = Engine.GetSummary(3, String.Empty); Summary.SummaryText = mySummary.sSummary; } else { // there was an error, in which case this needs to be handled somehow } }