private IDictionary<Emotions, float> CalculateAndRankScoreToDictionary(Scores emotionScores) { if (emotionScores == null) return null; IDictionary<Emotions, float> emotionRankingDictionary = new Dictionary<Emotions, float>(); foreach (PropertyInfo prop in emotionScores.GetType().GetProperties()) { for (int index = 0; index < Enum.GetNames(typeof(Emotions)).Length; index++) { string emotionName = Enum.GetNames(typeof(Emotions))[index]; if (!prop.Name.Contains(emotionName)) { continue; } Emotions parsedEmotion = Emotions.None; Enum.TryParse(emotionName, out parsedEmotion); emotionRankingDictionary.Add(parsedEmotion, (float)prop.GetValue(emotionScores)); } } //Sort and set highest value on top return emotionRankingDictionary.OrderByDescending(x => x.Value).ToDictionary(x => x.Key, x => x.Value); }
private IList<EmotionRank> CalculateAndRankScore(Scores emotionScores) { if (emotionScores == null) return null; IList<EmotionRank> emotionRankingList = new List<EmotionRank>(); foreach (PropertyInfo prop in emotionScores.GetType().GetProperties()) { for (int index = 0; index < Enum.GetNames(typeof(Emotions)).Length; index++) { string emotionName = Enum.GetNames(typeof(Emotions))[index]; if (!prop.Name.Contains(emotionName)) { continue; } Emotions parsedEmotion = Emotions.None; Enum.TryParse(emotionName, out parsedEmotion); emotionRankingList.Add(new EmotionRank() { Emotion = parsedEmotion, Rank = (float)prop.GetValue(emotionScores) }); } } //Sort and set highest value on top return emotionRankingList.OrderByDescending(x => x.Rank).ToList(); }
public RoverTable(Scores S) { this.Anger = S.Anger; this.Contempt = S.Contempt; this.Disgust = S.Disgust; this.Fear = S.Fear; this.Happiness = S.Happiness; this.Neutral = S.Neutral; this.Sadness = S.Sadness; this.Surprise = S.Surprise; }
public void Update(Scores x) { Emotions.Clear(); Emotions.Add(new EmoCollectionRecord() { Emotion = "Happiness", Value = x.Happiness }); Emotions.Add(new EmoCollectionRecord() { Emotion = "Anger", Value = x.Anger }); Emotions.Add(new EmoCollectionRecord() { Emotion = "Contempt", Value = x.Contempt }); Emotions.Add(new EmoCollectionRecord() { Emotion = "Disgust", Value = x.Disgust }); Emotions.Add(new EmoCollectionRecord() { Emotion = "Fear", Value = x.Fear, }); Emotions.Add(new EmoCollectionRecord() { Emotion = "Sadness", Value = x.Sadness }); Emotions.Add(new EmoCollectionRecord() { Emotion = "Surprise", Value = x.Surprise }); }
public void Update(Scores x) { Emotions.Clear(); Emotions.Add(new EmoCollectionRecord() { Emotion = "Счастье", Value = x.Happiness }); Emotions.Add(new EmoCollectionRecord() { Emotion = "Гнев", Value = x.Anger }); Emotions.Add(new EmoCollectionRecord() { Emotion = "Презрение", Value = x.Contempt }); Emotions.Add(new EmoCollectionRecord() { Emotion = "Отвращение", Value = x.Disgust }); Emotions.Add(new EmoCollectionRecord() { Emotion = "Страх", Value = x.Fear, }); Emotions.Add(new EmoCollectionRecord() { Emotion = "Печаль", Value = x.Sadness }); Emotions.Add(new EmoCollectionRecord() { Emotion = "Удивление", Value = x.Surprise }); }
public static async Task Insert(Scores S) { var rovertable = Client.GetTable<RoverTable>(); var rt = new RoverTable(S); await rovertable.InsertAsync(rt); }
public EmoCollection(Scores x) { Emotions = new ObservableCollection<EmoCollectionRecord>(); Update(x); }