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:
parent
53138e6942
commit
1ca6ec52fd
@ -42,18 +42,19 @@ class CentroidConversion(EmotionConversionPlugin):
|
||||
for e in original.onyx__hasEmotion:
|
||||
category = e.onyx__hasEmotionCategory
|
||||
intensity = e.get("onyx__hasEmotionIntensity",1)
|
||||
if intensity == 0:
|
||||
continue
|
||||
if category in self.centroids:
|
||||
totalIntensities[category] += intensity
|
||||
for dim, value in self.centroids[category].items():
|
||||
totalIntensities[dim] += intensity
|
||||
try:
|
||||
res[dim] += value * intensity
|
||||
except Exception:
|
||||
res[dim] = value * intensity
|
||||
|
||||
for dim,intensity in totalIntensities.items():
|
||||
if intensity != 0:
|
||||
res[dim] /= intensity
|
||||
else:
|
||||
res[dim] = self.centroids.get('neutral', {dim:0})[dim]
|
||||
return res
|
||||
|
||||
def _backwards_conversion(self, original):
|
||||
|
Loading…
Reference in New Issue
Block a user