mirror of
https://github.com/gsi-upm/senpy
synced 2025-09-18 20:42:22 +00:00
New schema for parameters
* Add parameters as an entity in the schema * Update examples to include parameters * Change the API for processing plugins, params is a parameter again, instead of only adding the request. * Update tests
This commit is contained in:
@@ -5,7 +5,8 @@ import jsonschema
|
||||
import json
|
||||
import rdflib
|
||||
from unittest import TestCase
|
||||
from senpy.models import (Emotion,
|
||||
from senpy.models import (Analysis,
|
||||
Emotion,
|
||||
EmotionAnalysis,
|
||||
EmotionSet,
|
||||
Entry,
|
||||
@@ -61,7 +62,7 @@ class ModelsTest(TestCase):
|
||||
def test_id(self):
|
||||
""" Adding the id after creation should overwrite the automatic ID
|
||||
"""
|
||||
r = Entry()
|
||||
r = Entry(_auto_id=True)
|
||||
j = r.jsonld()
|
||||
assert '@id' in j
|
||||
r.id = "test"
|
||||
@@ -189,6 +190,19 @@ class ModelsTest(TestCase):
|
||||
assert isinstance(js['plugins'], list)
|
||||
assert js['plugins'][0]['@type'] == 'sentimentPlugin'
|
||||
|
||||
def test_parameters(self):
|
||||
'''An Analysis should contain the algorithm and the list of parameters to be used'''
|
||||
a = Analysis()
|
||||
a.params = {'param1': 1, 'param2': 2}
|
||||
assert len(a.parameters) == 2
|
||||
for param in a.parameters:
|
||||
if param.name == 'param1':
|
||||
assert param.value == 1
|
||||
elif param.name == 'param2':
|
||||
assert param.value == 2
|
||||
else:
|
||||
raise Exception('Unknown value %s' % param)
|
||||
|
||||
def test_from_string(self):
|
||||
results = {
|
||||
'@type': 'results',
|
||||
|
Reference in New Issue
Block a user