1
0
mirror of https://github.com/gsi-upm/senpy synced 2024-12-22 13:08:13 +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)
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()
totalIntensities = defaultdict(float)
maxIntensity = float(original.get("onyx__maxIntensityValue",1))
sumIntensities = 0
neutralPoint = self.get("origin",None)
for e in original.onyx__hasEmotion:
category = e.onyx__hasEmotionCategory
intensity = e.get("onyx__hasEmotionIntensity",1)
intensity = e.get("onyx__hasEmotionIntensity",maxIntensity)/maxIntensity
if intensity == 0:
continue
if category in self.centroids:
for dim, value in self.centroids[category].items():
totalIntensities[dim] += intensity
sumIntensities += intensity
centoid = self.centroids.get(category,None)
if centroid:
for dim, value in centroid.items():
if neutralPoint:
value -= neutralPoint[dim]
try:
res[dim] += value * intensity
except KeyError:
res[dim] = value * intensity
for dim,intensity in totalIntensities.items():
if intensity != 0:
res[dim] /= intensity
if neutralPoint:
for dim in res:
res[dim] += neutralPoint[dim]
return res
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
version: 0.1
# 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:
anger:
A: 6.95
@ -25,6 +30,10 @@ centroids:
A: 5.21
D: 2.82
V: 2.21
neutral:
A: 5.00
D: 2.00
V: 5.00
centroids_direction:
- emoml:big6
- emoml:pad