コード例 #1
0
        /// <summary>
        /// A recursive search for the dominant emotion in a node and its children
        /// </summary>
        /// <param name="node">The node to be searched</param>
        /// <param name="dominantEmotions">The dominant emotions found</param>
        /// <param name="largestValue">The largest emotional intensity found so far</param>
        private void findDominantEmotion(EmotionNode node, List <EmotionType> dominantEmotions, ref double largestValue)
        {
            if (node.PositiveEmotionValue > largestValue)
            {
                dominantEmotions.Clear();
                dominantEmotions.Add(node.PositiveEmotion);
                largestValue = node.PositiveEmotionValue;
            }

            if (node.NegativeEmotionValue > largestValue)
            {
                dominantEmotions.Clear();
                dominantEmotions.Add(node.NegativeEmotion);
                largestValue = node.NegativeEmotionValue;
            }

            if (node.PositiveEmotionValue == largestValue && !dominantEmotions.Contains(node.PositiveEmotion))
            {
                dominantEmotions.Add(node.PositiveEmotion);
            }

            if (node.NegativeEmotionValue == largestValue && !dominantEmotions.Contains(node.NegativeEmotion))
            {
                dominantEmotions.Add(node.NegativeEmotion);
            }

            foreach (EmotionNode child in node.Children)
            {
                findDominantEmotion(child, dominantEmotions, ref largestValue);
            }
        }
コード例 #2
0
        /// <summary>
        /// The recursive save function used only by backupTree()
        /// </summary>
        /// <param name="node">The node to be gone through</param>
        private void backupTreeRecursive(EmotionNode node)
        {
            node.backupState();

            foreach (EmotionNode child in node.Children)
            {
                child.backupState();
            }
        }
コード例 #3
0
        /// <summary>
        /// Add to the intensity of a specific emotion in the tree
        /// </summary>
        /// <param name="et">The emotion type to add to</param>
        /// <param name="value">The intensity to add</param>
        public void addToEmotion(EmotionType et, double value)
        {
            EmotionNode node = getNode(et);

            if (node != null)
            {
                node.addToEmotion(et, value);
            }
        }
コード例 #4
0
        /// <summary>
        /// Perform a top recursive search of all the nodes in the tree for
        /// the specified emotion.
        /// </summary>
        /// <param name="et">The emotion to search for</param>
        /// <returns>The emotion node containing the emotion if found, otherwise null</returns>
        public EmotionNode getNode(EmotionType et)
        {
            foreach (EmotionNode child in _root)
            {
                EmotionNode result = recursiveSearch(child, et);
                if (result != null)
                {
                    return(result);
                }
            }

            return(null);
        }
コード例 #5
0
        public double this[EmotionType et, int index]
        {
            get
            {
                EmotionNode node = getNode(et);

                if (node != null)
                {
                    return(node.EmotionValue(et, index));
                }
                else
                {
                    return(-99999);
                }
            }
        }
コード例 #6
0
        /// <summary>
        /// The recursive component of getNode()
        /// </summary>
        /// <param name="node">The node to search</param>
        /// <param name="et">The emotion to search for</param>
        /// <returns>The emotion node containing the emotion if found, otherwise null</returns>
        private EmotionNode recursiveSearch(EmotionNode node, EmotionType et)
        {
            if (node.Represents(et))
            {
                return(node);
            }
            else
            {
                foreach (EmotionNode child in node.Children)
                {
                    EmotionNode result = recursiveSearch(child, et);
                    if (result != null)
                    {
                        return(result);
                    }
                }
            }

            return(null);
        }
コード例 #7
0
        public PersonalityModel(double joy, double distress, double pride, double shame, double admiration, double reproach, double love,
                                double hate, double interest, double disgust, double gratification, double remorse, double gratitude,
                                double anger, double happyfor, double resentment, double gloating, double pity, double hope, double fear,
                                double neuroticism, double introversion, double openness, double agreeableness, double conscientiousness)
        {
            _joyDistressNode          = new EmotionNode(EmotionType.Joy, joy, EmotionType.Distress, distress);
            _prideShameNode           = new EmotionNode(EmotionType.Pride, pride, EmotionType.Shame, shame);
            _admirationReproachNode   = new EmotionNode(EmotionType.Admiration, admiration, EmotionType.Reproach, reproach);
            _loveHateNode             = new EmotionNode(EmotionType.Love, love, EmotionType.Hate, hate);
            _interestDisgustNode      = new EmotionNode(EmotionType.Interest, interest, EmotionType.Disgust, disgust);
            _gratificationRemorseNode = new EmotionNode(EmotionType.Gratification, gratification, EmotionType.Remorse, remorse);
            _happyforResentmentNode   = new EmotionNode(EmotionType.HappyFor, happyfor, EmotionType.Resentment, resentment);
            _gloatingPityNode         = new EmotionNode(EmotionType.Gloating, gloating, EmotionType.Pity, pity);
            _hopeFearNode             = new EmotionNode(EmotionType.Hope, hope, EmotionType.Fear, fear);
            _gratitudeAngerNode       = new EmotionNode(EmotionType.Gratitude, gratitude, EmotionType.Anger, anger);

            SetUpEmotionTree();

            Neuroticism       = neuroticism;
            Introversion      = introversion;
            Openness          = openness;
            Agreeableness     = agreeableness;
            Conscientiousness = conscientiousness;
        }
コード例 #8
0
 public void Add(EmotionNode node)
 {
     _root.Add(node);
 }
コード例 #9
0
 /// <summary>
 /// Add a child to this node
 /// </summary>
 /// <param name="node">The child node</param>
 public void Add(EmotionNode node)
 {
     children.Add(node);
     node.parents.Add(this);
 }