From 3a33e405e7a53c8c98c56e2233b4e32b076a35a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=2E=20Fernando=20S=C3=A1nchez?= Date: Sun, 13 Jul 2014 17:02:05 +0200 Subject: [PATCH] Less random --- app.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app.py b/app.py index 78e3947..5787ff1 100644 --- a/app.py +++ b/app.py @@ -22,7 +22,7 @@ This class shows how to use the nif_server module to create custom services. import config import re from flask import Flask -from random import random +import random from nif_server import * app = Flask(__name__) @@ -31,13 +31,16 @@ rgx = re.compile("(\w[\w']*\w|\w)", re.U) def hard_analysis(params): response = basic_analysis(params) - response["analysis"][0]["marl:algorithm"] = "SimpleAlgorithm" + response["analysis"][0].update({ "marl:algorithm": "SimpleAlgorithm", + "marl:minPolarityValue": -1, + "marl:maxPolarityValue": 1}) for i in response["entries"]: contextid = i["@id"] - polValue = random() - if polValue > 0.5: + random.seed(str(params)) + polValue = 2*random.random()-1 + if polValue > 0: pol = "marl:Positive" - elif polValue == 0.5: + elif polValue == 0: pol = "marl:Neutral" else: pol = "marl:Negative"