Commit 1ca6ec52 authored by Ian Wood's avatar Ian Wood
Browse files

fixed weighted average, no explicit treatment of 'neutral'

parent 53138e69
......@@ -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:
if category in self.centroids:
totalIntensities[category] += intensity
for dim, value in self.centroids[category].items():
totalIntensities[dim] += intensity
res[dim] += value * intensity
except Exception:
res[dim] = value * intensity
for dim,intensity in totalIntensities.items():
if intensity != 0:
res[dim] /= intensity
res[dim] = self.centroids.get('neutral', {dim:0})[dim]
return res
def _backwards_conversion(self, original):
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment