mirror of
https://github.com/gsi-upm/senpy
synced 2025-10-24 04:08:19 +00:00
Closes #40
This commit is contained in:
@@ -100,3 +100,54 @@ class CentroidConversion(EmotionConversionPlugin):
|
||||
else:
|
||||
raise Error('EMOTION MODEL NOT KNOWN')
|
||||
yield e
|
||||
|
||||
def test(self, info=None):
|
||||
if not info:
|
||||
info = {
|
||||
"name": "CentroidTest",
|
||||
"description": "Centroid test",
|
||||
"version": 0,
|
||||
"centroids": {
|
||||
"c1": {"V1": 0.5,
|
||||
"V2": 0.5},
|
||||
"c2": {"V1": -0.5,
|
||||
"V2": 0.5},
|
||||
"c3": {"V1": -0.5,
|
||||
"V2": -0.5},
|
||||
"c4": {"V1": 0.5,
|
||||
"V2": -0.5}},
|
||||
"aliases": {
|
||||
"V1": "X-dimension",
|
||||
"V2": "Y-dimension"
|
||||
},
|
||||
"centroids_direction": ["emoml:big6", "emoml:fsre-dimensions"]
|
||||
}
|
||||
|
||||
c = CentroidConversion(info)
|
||||
|
||||
es1 = EmotionSet()
|
||||
e1 = Emotion()
|
||||
e1.onyx__hasEmotionCategory = "c1"
|
||||
es1.onyx__hasEmotion.append(e1)
|
||||
res = c._forward_conversion(es1)
|
||||
assert res["X-dimension"] == 0.5
|
||||
assert res["Y-dimension"] == 0.5
|
||||
|
||||
e2 = Emotion()
|
||||
e2.onyx__hasEmotionCategory = "c2"
|
||||
es1.onyx__hasEmotion.append(e2)
|
||||
res = c._forward_conversion(es1)
|
||||
assert res["X-dimension"] == 0
|
||||
assert res["Y-dimension"] == 1
|
||||
|
||||
e = Emotion()
|
||||
e["X-dimension"] = -0.2
|
||||
e["Y-dimension"] = -0.3
|
||||
res = c._backwards_conversion(e)
|
||||
assert res["onyx:hasEmotionCategory"] == "c3"
|
||||
|
||||
e = Emotion()
|
||||
e["X-dimension"] = -0.2
|
||||
e["Y-dimension"] = 0.3
|
||||
res = c._backwards_conversion(e)
|
||||
assert res["onyx:hasEmotionCategory"] == "c2"
|
||||
|
||||
Reference in New Issue
Block a user