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
60ef3041
Commit
60ef3041
authored
May 05, 2017
by
J. Fernando Sánchez
Browse files
Analysis set as a python list
Closes
#31
parent
13cefbed
Changes
2
Hide whitespace changes
Inline
Side-by-side
senpy/extensions.py
View file @
60ef3041
...
...
@@ -195,7 +195,7 @@ class Senpy(object):
def
convert_emotions
(
self
,
resp
,
plugins
,
params
):
"""
Conversion of all emotions in a response.
Conversion of all emotions in a response
**in place**
.
In addition to converting from one model to another, it has
to include the conversion plugin to the analysis list.
Needless to say, this is far from an elegant solution, but it works.
...
...
@@ -220,7 +220,6 @@ class Senpy(object):
e
.
parameters
=
params
raise
e
newentries
=
[]
resp
.
analysis
=
set
(
resp
.
analysis
)
for
i
in
resp
.
entries
:
if
output
==
"full"
:
newemotions
=
copy
.
deepcopy
(
i
.
emotions
)
...
...
@@ -229,7 +228,7 @@ class Senpy(object):
for
j
in
i
.
emotions
:
plugname
=
j
[
'prov:wasGeneratedBy'
]
candidate
=
candidates
[
plugname
]
resp
.
analysis
.
a
d
d
(
candidate
.
id
)
resp
.
analysis
.
a
ppen
d
(
candidate
.
id
)
for
k
in
candidate
.
convert
(
j
,
fromModel
,
toModel
,
params
):
k
.
prov__wasGeneratedBy
=
candidate
.
id
if
output
==
'nested'
:
...
...
@@ -238,6 +237,7 @@ class Senpy(object):
i
.
emotions
=
newemotions
newentries
.
append
(
i
)
resp
.
entries
=
newentries
resp
.
analysis
=
list
(
set
(
resp
.
analysis
))
@
property
def
default_plugin
(
self
):
...
...
tests/test_extensions.py
View file @
60ef3041
...
...
@@ -205,6 +205,7 @@ class ExtensionsTest(TestCase):
[
plugin
,
],
params
)
assert
len
(
r3
.
entries
[
0
].
emotions
)
==
1
r3
.
jsonld
()
# def test_async_plugin(self):
# """ We should accept multiprocessing plugins with async=False"""
...
...
Write
Preview
Markdown
is supported
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