1
0
mirror of https://github.com/gsi-upm/senpy synced 2024-09-28 17:01:43 +00:00

Analysis set as a python list

Closes senpy/senpy#31
This commit is contained in:
J. Fernando Sánchez 2017-05-05 17:05:17 +02:00
parent 13cefbedfb
commit 60ef304108
2 changed files with 4 additions and 3 deletions

View File

@ -195,7 +195,7 @@ class Senpy(object):
def convert_emotions(self, resp, plugins, params): 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 In addition to converting from one model to another, it has
to include the conversion plugin to the analysis list. to include the conversion plugin to the analysis list.
Needless to say, this is far from an elegant solution, but it works. Needless to say, this is far from an elegant solution, but it works.
@ -220,7 +220,6 @@ class Senpy(object):
e.parameters = params e.parameters = params
raise e raise e
newentries = [] newentries = []
resp.analysis = set(resp.analysis)
for i in resp.entries: for i in resp.entries:
if output == "full": if output == "full":
newemotions = copy.deepcopy(i.emotions) newemotions = copy.deepcopy(i.emotions)
@ -229,7 +228,7 @@ class Senpy(object):
for j in i.emotions: for j in i.emotions:
plugname = j['prov:wasGeneratedBy'] plugname = j['prov:wasGeneratedBy']
candidate = candidates[plugname] candidate = candidates[plugname]
resp.analysis.add(candidate.id) resp.analysis.append(candidate.id)
for k in candidate.convert(j, fromModel, toModel, params): for k in candidate.convert(j, fromModel, toModel, params):
k.prov__wasGeneratedBy = candidate.id k.prov__wasGeneratedBy = candidate.id
if output == 'nested': if output == 'nested':
@ -238,6 +237,7 @@ class Senpy(object):
i.emotions = newemotions i.emotions = newemotions
newentries.append(i) newentries.append(i)
resp.entries = newentries resp.entries = newentries
resp.analysis = list(set(resp.analysis))
@property @property
def default_plugin(self): def default_plugin(self):

View File

@ -205,6 +205,7 @@ class ExtensionsTest(TestCase):
[plugin, ], [plugin, ],
params) params)
assert len(r3.entries[0].emotions) == 1 assert len(r3.entries[0].emotions) == 1
r3.jsonld()
# def test_async_plugin(self): # def test_async_plugin(self):
# """ We should accept multiprocessing plugins with async=False""" # """ We should accept multiprocessing plugins with async=False"""