Пример #1
0
        public void Appraisal(KB kb, IBaseEvent evt, IWritableAppraisalFrame frame)
        {
            AppraisalRule activeRule = Evaluate(evt, kb, kb.Perspective);

            if (activeRule != null)
            {
                if (activeRule.Desirability != null)
                {
                    float des;
                    if (!float.TryParse(activeRule.Desirability.ToString(), out des))
                    {
                        throw new ArgumentException("Desirability can only be a float value");
                    }
                    frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY, des);
                }

                if (activeRule.Praiseworthiness != null)
                {
                    float p;
                    if (!float.TryParse(activeRule.Praiseworthiness.ToString(), out p))
                    {
                        throw new ArgumentException("Desirability can only be a float value");
                    }
                    frame.SetAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS, p);
                }
            }
        }
Пример #2
0
        public void Appraisal(KB kb, IBaseEvent evt, IWritableAppraisalFrame frame)
        {
            AppraisalRule activeRule = Evaluate(evt, kb, kb.Perspective);

            if (activeRule != null)
            {
                foreach (var appVar in activeRule.getAppraisalVariables())
                {
                    float des;
                    if (!float.TryParse(appVar.Value.ToString(), out des))
                    {
                        throw new ArgumentException(appVar.Name + " can only be a float value");
                    }


                    if (appVar.Name == OCCAppraisalVariables.GOALSUCCESSPROBABILITY)
                    {
                        frame.SetAppraisalVariable(OCCAppraisalVariables.GOALSUCCESSPROBABILITY + " " + appVar.Target, des);
                    }

                    else if (appVar.Name == OCCAppraisalVariables.PRAISEWORTHINESS)
                    {
                        frame.SetAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS + " " + appVar.Target, des);
                    }

                    else
                    {
                        frame.SetAppraisalVariable(appVar.Name, des);
                    }

                    if (appVar.Target != null && appVar.Target != (Name)"-" && appVar.Target != (Name)"SELF")
                    {
                        frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER + "" + appVar.Target, des);
                    }
                }
            }
        }
Пример #3
0
        public void InverseAffectDerivation(EmotionalAppraisalAsset emotionalModule, IEmotion emotion, IWritableAppraisalFrame frame)
        {
            const float MAGIC_VALUE_FOR_LOVE = 1.43f;
            //TODO improve this code

            //ignoring mood for now

            EmotionDispositionDTO emotionDisposition = emotionalModule.EmotionDispositions.FirstOrDefault(e => e.Emotion == emotion.EmotionType);

            if (emotionDisposition == null)
            {
                emotionDisposition = emotionalModule.DefaultEmotionDisposition;
            }

            int   threshold      = emotionDisposition.Threshold;
            float potentialValue = emotion.Potential + threshold;

            if (emotion.EmotionType == OCCEmotionType.Love.Name)
            {
                frame.SetAppraisalVariable(OCCAppraisalVariables.LIKE, potentialValue * MAGIC_VALUE_FOR_LOVE);
            }
            else if (emotion.EmotionType == OCCEmotionType.Hate.Name)
            {
                frame.SetAppraisalVariable(OCCAppraisalVariables.LIKE, potentialValue * -MAGIC_VALUE_FOR_LOVE);
            }
            else
            if (emotion.EmotionType == OCCEmotionType.Joy.Name)
            {
                frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY, potentialValue);
            }
            else if (emotion.EmotionType == OCCEmotionType.Distress.Name)
            {
                frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY, -potentialValue);
            }
            else if (emotion.EmotionType == OCCEmotionType.Pride.Name)
            {
                frame.SetAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS, potentialValue);
            }
            else if (emotion.EmotionType == OCCEmotionType.Shame.Name)
            {
                frame.SetAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS, -potentialValue);
            }
            else if (emotion.EmotionType == OCCEmotionType.Gloating.Name)
            {
                frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY, potentialValue);
                frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER, -potentialValue);
            }
            else if (emotion.EmotionType == OCCEmotionType.HappyFor.Name)
            {
                frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY, potentialValue);
                frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER, potentialValue);
            }
            else if (emotion.EmotionType == OCCEmotionType.Pitty.Name)
            {
                frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY, -potentialValue);
                frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER, -potentialValue);
            }
            else if (emotion.EmotionType == OCCEmotionType.Resentment.Name)
            {
                frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER, potentialValue);
            }
            else if (emotion.EmotionType == OCCEmotionType.Gratification.Name)
            {
                frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY, potentialValue);
                frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER, potentialValue);
            }
            else if (emotion.EmotionType == OCCEmotionType.Anger.Name)
            {
                frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY, -potentialValue);
                frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER, -potentialValue);
            }
        }
        public void Appraisal(EmotionalAppraisalAsset emotionalModule, IBaseEvent evt, IWritableAppraisalFrame frame)
        {
            AppraisalRule selfEvaluation = Evaluate(evt, emotionalModule,emotionalModule.Perspective);
            if (selfEvaluation != null)
            {
                if (selfEvaluation.Desirability != 0)
                    frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY, selfEvaluation.Desirability);

                //if (selfEvaluation.DesirabilityForOther != 0)
                //{
                //	string other;
                //	if (selfEvaluation.Other != null)
                //		other = selfEvaluation.Other.ToString();
                //	else if (evt.Target != null)
                //		other = evt.Target;
                //	else
                //		other = evt.Subject;

                //	frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER + other, selfEvaluation.DesirabilityForOther);
                //}

                if (selfEvaluation.Praiseworthiness != 0)
                    frame.SetAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS, selfEvaluation.Praiseworthiness);

                //if (selfEvaluation.Like != 0)
                //	frame.SetAppraisalVariable(OCCAppraisalVariables.LIKE, selfEvaluation.Like);
            }
        }
Пример #5
0
        public void Appraisal(EmotionalAppraisalAsset emotionalModule, IBaseEvent evt, IWritableAppraisalFrame frame)
        {
            AppraisalRule selfEvaluation = Evaluate(evt, emotionalModule.Kb);

            if (selfEvaluation != null)
            {
                if (selfEvaluation.Desirability != 0)
                {
                    frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY, selfEvaluation.Desirability);
                }

                //if (selfEvaluation.DesirabilityForOther != 0)
                //{
                //	string other;
                //	if (selfEvaluation.Other != null)
                //		other = selfEvaluation.Other.ToString();
                //	else if (evt.Target != null)
                //		other = evt.Target;
                //	else
                //		other = evt.Subject;

                //	frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER + other, selfEvaluation.DesirabilityForOther);
                //}

                if (selfEvaluation.Praiseworthiness != 0)
                {
                    frame.SetAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS, selfEvaluation.Praiseworthiness);
                }

                //if (selfEvaluation.Like != 0)
                //	frame.SetAppraisalVariable(OCCAppraisalVariables.LIKE, selfEvaluation.Like);
            }
        }
        public void InverseAffectDerivation(EmotionalAppraisalAsset emotionalModule, IEmotion emotion, IWritableAppraisalFrame frame)
        {
            //const float MAGIC_VALUE_FOR_LOVE = 1.43f;
            //TODO improve this code

            //ignoring mood for now

            EmotionDispositionDTO emotionDisposition = emotionalModule.EmotionDispositions.FirstOrDefault(e => e.Emotion == emotion.EmotionType);
            if (emotionDisposition == null)
            {
                emotionDisposition = emotionalModule.DefaultEmotionDisposition;
            }

            int threshold = emotionDisposition.Threshold;
            float potentialValue = emotion.Potential + threshold;

            //if(emotion.EmotionType == OCCEmotionType.Love.Name)
            //{
            //	frame.SetAppraisalVariable(OCCAppraisalVariables.LIKE, potentialValue * MAGIC_VALUE_FOR_LOVE);
            //}
            //else if(emotion.EmotionType == OCCEmotionType.Hate.Name)
            //{
            //	frame.SetAppraisalVariable(OCCAppraisalVariables.LIKE, potentialValue * -MAGIC_VALUE_FOR_LOVE);
            //}
            //else
            if (emotion.EmotionType == OCCEmotionType.Joy.Name)
            {
                frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY, potentialValue);
            }
            else if (emotion.EmotionType == OCCEmotionType.Distress.Name)
            {
                frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY, -potentialValue);
            }
            else if (emotion.EmotionType == OCCEmotionType.Pride.Name)
            {
                frame.SetAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS, potentialValue);
            }
            else if (emotion.EmotionType == OCCEmotionType.Shame.Name)
            {
                frame.SetAppraisalVariable(OCCAppraisalVariables.PRAISEWORTHINESS, -potentialValue);
            }
            //else if (emotion.EmotionType == OCCEmotionType.Gloating.Name)
            //{
            //	frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY, potentialValue);
            //	frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER, -potentialValue);
            //}
            //else if (emotion.EmotionType == OCCEmotionType.HappyFor.Name)
            //{
            //	frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY, potentialValue);
            //	frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER, potentialValue);
            //}
            //else if (emotion.EmotionType == OCCEmotionType.Pitty.Name)
            //{
            //	frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY, -potentialValue);
            //	frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER, -potentialValue);
            //}
            //else if (emotion.EmotionType == OCCEmotionType.Resentment.Name)
            //{
            //	frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER, potentialValue);
            //}
            //else if (emotion.EmotionType == OCCEmotionType.Gratification.Name)
            //{
            //	frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY, potentialValue);
            //	frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER, potentialValue);
            //}
            //else if (emotion.EmotionType == OCCEmotionType.Anger.Name)
            //{
            //	frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY, -potentialValue);
            //	frame.SetAppraisalVariable(OCCAppraisalVariables.DESIRABILITY_FOR_OTHER, -potentialValue);
            //}
        }