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

fixed weighted average, no explicit treatment of 'neutral'

This commit is contained in:
Ian Wood 2017-04-11 11:12:02 +01:00
parent 53138e6942
commit 1ca6ec52fd

View File

@ -42,18 +42,19 @@ class CentroidConversion(EmotionConversionPlugin):
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",1)
if intensity == 0:
continue
if category in self.centroids: if category in self.centroids:
totalIntensities[category] += intensity
for dim, value in self.centroids[category].items(): for dim, value in self.centroids[category].items():
totalIntensities[dim] += intensity
try: try:
res[dim] += value * intensity res[dim] += value * intensity
except Exception: except Exception:
res[dim] = value * intensity res[dim] = value * intensity
for dim,intensity in totalIntensities.items(): for dim,intensity in totalIntensities.items():
if intensity != 0: if intensity != 0:
res[dim] /= intensity res[dim] /= intensity
else:
res[dim] = self.centroids.get('neutral', {dim:0})[dim]
return res return res
def _backwards_conversion(self, original): def _backwards_conversion(self, original):