1
0
mirror of https://github.com/gsi-upm/senpy synced 2024-11-22 00:02:28 +00:00

added 'origin' to VAD representation, incorporated into weighed sum for Cat->VAD conversion

This commit is contained in:
Ian Wood 2017-05-08 14:28:51 +01:00
parent 1a9dd07f7e
commit ec1a2ff5f9
2 changed files with 23 additions and 10 deletions

View File

@ -36,25 +36,29 @@ class CentroidConversion(EmotionConversionPlugin):
super(CentroidConversion, self).__init__(info) super(CentroidConversion, self).__init__(info)
def _forward_conversion(self, original): def _forward_conversion(self, original):
"""Sum the VAD value of all categories found.""" """Sum the VAD value of all categories found weighted by intensity. """
res = Emotion() res = Emotion()
totalIntensities = defaultdict(float) maxIntensity = float(original.get("onyx__maxIntensityValue",1))
sumIntensities = 0
neutralPoint = self.get("origin",None)
for e in original.onyx__hasEmotion: for e in original.onyx__hasEmotion:
category = e.onyx__hasEmotionCategory category = e.onyx__hasEmotionCategory
intensity = e.get("onyx__hasEmotionIntensity",1) intensity = e.get("onyx__hasEmotionIntensity",maxIntensity)/maxIntensity
if intensity == 0: if intensity == 0:
continue continue
if category in self.centroids: sumIntensities += intensity
for dim, value in self.centroids[category].items(): centoid = self.centroids.get(category,None)
totalIntensities[dim] += intensity if centroid:
for dim, value in centroid.items():
if neutralPoint:
value -= neutralPoint[dim]
try: try:
res[dim] += value * intensity res[dim] += value * intensity
except KeyError: except KeyError:
res[dim] = value * intensity res[dim] = value * intensity
if neutralPoint:
for dim,intensity in totalIntensities.items(): for dim in res:
if intensity != 0: res[dim] += neutralPoint[dim]
res[dim] /= intensity
return res return res
def _backwards_conversion(self, original): def _backwards_conversion(self, original):

View File

@ -4,6 +4,11 @@ module: senpy.plugins.conversion.centroids
description: Plugin to convert emotion sets from Ekman to VAD description: Plugin to convert emotion sets from Ekman to VAD
version: 0.1 version: 0.1
# No need to specify onyx:doesConversion because centroids.py adds it automatically from centroids_direction # No need to specify onyx:doesConversion because centroids.py adds it automatically from centroids_direction
origin:
# Point in VAD space with no emotion (aka Neutral)
A: 5.0
D: 5.0
V: 5.0
centroids: centroids:
anger: anger:
A: 6.95 A: 6.95
@ -25,6 +30,10 @@ centroids:
A: 5.21 A: 5.21
D: 2.82 D: 2.82
V: 2.21 V: 2.21
neutral:
A: 5.00
D: 2.00
V: 5.00
centroids_direction: centroids_direction:
- emoml:big6 - emoml:big6
- emoml:pad - emoml:pad