Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
senpy
senpy
Commits
ec1a2ff5
Commit
ec1a2ff5
authored
May 08, 2017
by
Ian Wood
Browse files
added 'origin' to VAD representation, incorporated into weighed sum for Cat->VAD conversion
parent
1a9dd07f
Changes
2
Show whitespace changes
Inline
Side-by-side
senpy/plugins/conversion/centroids.py
View file @
ec1a2ff5
...
...
@@ -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
):
...
...
senpy/plugins/conversion/emotion/ekman2vad.senpy
View file @
ec1a2ff5
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment