Example #1
0
        public IList <EmotionTypes> EmotionShareData([FromRoute] int DialogId)
        {
            var emotionnumber      = _context.FaceEmotionGuid.Where(p => p.DialogId == DialogId).Count();
            List <EmotionTypes> ET = new List <EmotionTypes>();
            var ET1 = new EmotionTypes();

            ET1.emotionname = DialogId.ToString();
            ET1.share       = _context.FaceEmotionGuid.Where(p => p.EmotionType == "Neutral" && p.DialogId == DialogId).Count();
            ET.Add(ET1);

            var ET2 = new EmotionTypes();

            ET2.emotionname = "Happiness";
            ET2.share       = _context.FaceEmotionGuid.Where(p => p.DialogId == DialogId).Count();
            ET.Add(ET2);

            var ET3 = new EmotionTypes();

            ET3.emotionname = "Surprise";
            ET3.share       = _context.FaceEmotionGuid.Where(p => p.DialogId == DialogId && p.EmotionType == "Surprise").Count();
            ET.Add(ET3);

            var ET4 = new EmotionTypes();

            ET4.emotionname = "Anger";
            ET4.share       = _context.FaceEmotionGuid.Where(p => p.DialogId == DialogId && p.EmotionType == "Anger").Count();
            ET.Add(ET4);


            return(ET);
        }
Example #2
0
        public IList <EmotionTypes> EmotionShareData([FromRoute] int?DialogId)
        {
            var emotionnumber      = _context.FaceEmotionGuid.Where(p => p.DialogId == DialogId).Count();
            List <EmotionTypes> ET = new List <EmotionTypes>();

            if (emotionnumber == 0 || DialogId == null)
            {
                var ET1 = new EmotionTypes();
                ET1.emotionname = "Neutral";
                ET1.share       = 0;
                ET.Add(ET1);

                var ET2 = new EmotionTypes();
                ET2.emotionname = "Happiness";
                ET2.share       = 0;
                ET.Add(ET2);

                var ET3 = new EmotionTypes();
                ET3.emotionname = "Surprise";
                ET3.share       = 0;
                ET.Add(ET3);

                var ET4 = new EmotionTypes();
                ET4.emotionname = "Anger";
                ET4.share       = 0;
                ET.Add(ET4);
                return(ET);
            }
            else
            {
                var ET1 = new EmotionTypes();
                ET1.emotionname = "Neutral";
                ET1.share       = Convert.ToInt32((_context.FaceEmotionGuid.Where(p => p.EmotionType == "Neutral" && p.DialogId == DialogId).Count() * 100) / emotionnumber);
                ET.Add(ET1);

                var ET2 = new EmotionTypes();
                ET2.emotionname = "Happiness";
                ET2.share       = Convert.ToInt32((_context.FaceEmotionGuid.Where(p => p.EmotionType == "Happiness" && p.DialogId == DialogId).Count() * 100) / emotionnumber);
                ET.Add(ET2);

                var ET3 = new EmotionTypes();
                ET3.emotionname = "Surprise";
                ET3.share       = Convert.ToInt32((_context.FaceEmotionGuid.Where(p => p.EmotionType == "Surprise" && p.DialogId == DialogId).Count() * 100) / emotionnumber);
                ET.Add(ET3);

                var ET4 = new EmotionTypes();
                ET4.emotionname = "Anger";
                ET4.share       = Convert.ToInt32((_context.FaceEmotionGuid.Where(p => p.EmotionType == "Anger" && p.DialogId == DialogId).Count() * 100) / emotionnumber);
                ET.Add(ET4);

                return(ET);
            }
        }
Example #3
0
        public IEmotion Get(EmotionTypes emotionTypes)
        {
            switch (emotionTypes)
            {
            case EmotionTypes.Happiness:
                return(new Happiness());

            case EmotionTypes.Love:
                return(new Love());

            default:
                throw new System.Exception();
            }
        }