Пример #1
0
        // + "?type=" + type + "&language=" + language
        public List <EmotionList> GetEmotions(string type, string format, string apiToken, string apiTokenSecret)
        {
            SinaApiService myApi    = new SinaApiService();
            string         myResult = myApi.GetEmotions(type, "cnname", format, consumerKey, consumerKeySecret, apiToken, apiTokenSecret);
            XDocument      doc      = XDocument.Parse(myResult);

            return(EmotionList.Parse(doc.Root));
        }
Пример #2
0
        public Sentance(IList <Word> words)
        {
            this.Words        = words;
            this.EmotionList  = new List <Emotion>();
            this.FeelingsList = new Dictionary <string, int>();

            for (int i = 0; i < GlobalVariables.emotions.Length; i++)
            {
                int score     = 0;
                int wordsUsed = 0;
                foreach (var word in words)
                {
                    var wordScore = word.EmotionList[i].Score;
                    if (wordScore != 0)
                    {
                        score += word.EmotionList[i].Score;
                        wordsUsed++;
                    }
                }

                if (wordsUsed == 0)
                {
                    wordsUsed = 1;
                }

                EmotionList.Add(
                    new Emotion()
                {
                    Name  = GlobalVariables.emotions[i].ToLower().Trim(),
                    Score = (byte)(score / wordsUsed)
                });
            }

            var feels = GlobalVariables.feelings;

            for (int i = 0; i < feels.Length; i++)
            {
                byte leftEmotionScore  = 0;
                byte rightEmotionScore = 0;

                if (i != feels.Length - 1)
                {
                    leftEmotionScore  = EmotionList.ElementAt(i).Score;
                    rightEmotionScore = EmotionList.ElementAt(i + 1).Score;
                }
                else
                {
                    leftEmotionScore  = EmotionList.ElementAt(i).Score;
                    rightEmotionScore = EmotionList.ElementAt(0).Score;
                }

                FeelingsList.Add(feels[i], leftEmotionScore + rightEmotionScore);
            }
        }
Пример #3
0
        public Word(string word, byte[] meaning)
        {
            this.Text        = word;
            this.EmotionList = new List <Emotion>();

            for (int i = 0; i < GlobalVariables.emotions.Length; i++)
            {
                EmotionList.Add(
                    new Emotion()
                {
                    Name  = GlobalVariables.emotions[i].ToLower().Trim(),
                    Score = meaning[i]
                });
            }
        }
 private void resetList()
 {
     EmotionList.Clear(); PhraseList.Clear(); ModelSentimentList.Clear();
 }