00001 /* 00002 * EmotionML.h 00003 * semaine 00004 * 00005 * Created by Marc Schröder on 06.11.08. 00006 * Copyright 2008 DFKI GmbH. All rights reserved. 00007 * 00008 */ 00009 00010 #ifndef SEMAINE_DATATYPES_XML_EMOTIONML_H 00011 #define SEMAINE_DATATYPES_XML_EMOTIONML_H 00012 00013 #include <semaine/config.h> 00014 00015 namespace semaine { 00016 namespace datatypes { 00017 namespace xml { 00025 class EmotionML 00026 { 00027 public: 00028 static const std::string namespaceURI; 00029 static const std::string version; 00030 00031 // Elements 00032 static const std::string E_EMOTIONML; 00033 static const std::string E_EMOTION; 00034 static const std::string E_ROOT_TAGNAME; 00035 static const std::string E_CATEGORY; 00036 static const std::string E_DIMENSION; 00037 static const std::string E_APPRAISAL; 00038 static const std::string E_ACTION_TENDENCY; 00039 static const std::string E_INTENSITY; 00040 static const std::string E_INFO; 00041 static const std::string E_REFERENCE; 00042 static const std::string E_TRACE; 00043 00044 // Attributes 00045 // Attributes of <emotion> 00046 static const std::string A_CATEGORY_VOCABULARY; 00047 static const std::string A_DIMENSION_VOCABULARY; 00048 static const std::string A_APPRAISAL_VOCABULARY; 00049 static const std::string A_ACTION_TENDENCY_VOCABULARY; 00050 static const std::string A_ID; 00051 static const std::string A_START; 00052 static const std::string A_END; 00053 static const std::string A_VERSION; 00054 static const std::string A_MODALITY; 00055 00056 // Attributes of <category>, <dimension>, <appraisal>, <action-tendency> and <intensity> 00057 static const std::string A_NAME; 00058 static const std::string A_VALUE; 00059 static const std::string A_CONFIDENCE; 00060 00061 // Attributes of <reference> 00062 static const std::string A_URI; 00063 static const std::string A_ROLE; 00064 static const std::string A_MEDIA_TYPE; 00065 00066 // Attributes of <trace> 00067 static const std::string A_FREQ; 00068 static const std::string A_SAMPLES; 00069 00070 // Values 00071 00072 // Values of A_ROLE: 00073 static const std::string V_EXPRESSED_BY; 00074 static const std::string V_EXPERIENCED_BY; 00075 static const std::string V_TRIGGERED_BY; 00076 static const std::string V_TARGETED_AT; 00077 00078 00079 // Selected vocabularies 00080 00081 // FSRE dimensions as in http://www.w3.org/TR/2010/WD-emotionml-20100729/#fsre-dimensions 00082 static const std::string VOC_FSRE_DIMENSION_DEFINITION; 00083 static const std::string VOC_FSRE_DIMENSION_VALENCE; 00084 static const std::string VOC_FSRE_DIMENSION_POTENCY; 00085 static const std::string VOC_FSRE_DIMENSION_AROUSAL; 00086 static const std::string VOC_FSRE_DIMENSION_UNPREDICTABILITY; 00087 00088 00089 // SEMAINE-specific dimension vocabulary containing only one dimension, "intensity": 00090 static const std::string VOC_SEMAINE_INTENSITY_DIMENSION_DEFINITON; 00091 static const std::string VOC_SEMAINE_INTENSITY_DIMENSION_INTENSITY; 00092 00093 // SEMAINE-specific set of interest-related categories: 00094 static const std::string VOC_SEMAINE_INTEREST_CATEGORY_DEFINITION; 00095 static const std::string VOC_SEMAINE_INTEREST_CATEGORY_BORED; 00096 static const std::string VOC_SEMAINE_INTEREST_CATEGORY_NEUTRAL; 00097 static const std::string VOC_SEMAINE_INTEREST_CATEGORY_INTERESTED; 00098 00099 00104 inline static float semaineArousal2FSREArousal(float semaineArousal) { 00105 return from11to01(semaineArousal); 00106 } 00107 00112 inline static float fsreArousal2SemaineArousal(float fsreArousal) { 00113 return from01to11(fsreArousal); 00114 } 00115 00120 inline static float semaineValence2FSREValence(float semaineValence) { 00121 return from11to01(semaineValence); 00122 } 00123 00128 inline static float fsreValence2SemaineValence(float fsreValence) { 00129 return from01to11(fsreValence); 00130 } 00131 00136 inline static float semainePower2FSREPotency(float semainePower) { 00137 return from11to01(semainePower); 00138 } 00139 00144 inline static float fsrePotency2SemainePower(float fsrePotency) { 00145 return from01to11(fsrePotency); 00146 } 00147 00152 inline static float semaineExpectation2FSREUnpredictability(float semaineExpectation) { 00153 return 1 - from11to01(semaineExpectation); // opposite polarity 00154 } 00155 00160 inline static float fsreUnpredictability2SemaineExpectation(float fsreUnpredictability) { 00161 return from01to11(fsreUnpredictability); 00162 } 00163 00164 private: 00170 inline static float from11to01(float valueIn11) { 00171 float valueIn01 = (valueIn11 + 1.f) * 0.5f; 00172 // and force into target interval 00173 return _max(0.f, _min(1.f, valueIn01)); 00174 } 00175 00181 inline static float from01to11(float valueIn01) { 00182 float valueIn11 = valueIn01 * 2.f - 1.f; 00183 // and force into target interval 00184 return _max(-1.f, _min(1.f, valueIn11)); 00185 } 00186 00187 inline static float _max(float a, float b) { 00188 return (a > b) ? a : b; 00189 } 00190 00191 inline static float _min(float a, float b) { 00192 return (a > b) ? b : a; 00193 } 00194 }; 00195 00196 } // namespace xml 00197 } // namespace datatypes 00198 } // namespace semaine 00199 00200 #endif 00201