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); } }
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] }); } }