Esempio n. 1
0
 // ---------------------------------------------------------------------------------------------
 private State recognizeEmotion(AffitsPad pad)
 {
     return(Array.Find(states,
                       s => inRange(pad.pleasure, s.pleasure.min, s.pleasure.max) &&
                       inRange(pad.arousal, s.arousal.min, s.arousal.max) &&
                       inRange(pad.dominance, s.dominance.min, s.dominance.max)
                       ).name);
 }
Esempio n. 2
0
 // ---------------------------------------------------------------------------------------------
 private bool isPeacefull(AffitsPad pad)
 {
     if (
         inRange(pad.pleasure, -okRange, okRange) &&
         inRange(pad.arousal, -okRange, okRange) &&
         inRange(pad.dominance, -okRange, okRange)
         )
     {
         return(true);
     }
     return(false);
 }
Esempio n. 3
0
        // PUBLIC
        // =============================================================================================
        public EmoState?interpret(string pad, int userId)
        {
            if (pad == "{\"PAD\":null}")
            {
                _logger.Debug("User: "******"|" + "Marking user state as undefined for null response");

                return(EmoState.UNDEFINED);
            }
            AffitsPad affitsPad;

            try {
                affitsPad = new AffitsPad(pad);
            } catch (Exception e) {
                _logger.Error("User: "******"|" + "Mapping pad: \"" + pad + "\" failed." + e.ToString());

                return(null);
            }
            EmoState interpreted;
            State?   stateName = null;

            if (isPeacefull(affitsPad))
            {
                interpreted = EmoState.OK;
            }
            else
            {
                stateName = recognizeEmotion(affitsPad);
                if (stateName == null)
                {
                    return(null);
                }
                interpreted = classifyState((State)stateName);
            }
            log(pad, interpreted, stateName, userId);

            return(interpreted);
        }