mirror of
https://github.com/gsi-upm/senpy
synced 2024-11-22 00:02:28 +00:00
Less random
This commit is contained in:
parent
ad326f4686
commit
3a33e405e7
13
app.py
13
app.py
@ -22,7 +22,7 @@ This class shows how to use the nif_server module to create custom services.
|
|||||||
import config
|
import config
|
||||||
import re
|
import re
|
||||||
from flask import Flask
|
from flask import Flask
|
||||||
from random import random
|
import random
|
||||||
from nif_server import *
|
from nif_server import *
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
@ -31,13 +31,16 @@ rgx = re.compile("(\w[\w']*\w|\w)", re.U)
|
|||||||
|
|
||||||
def hard_analysis(params):
|
def hard_analysis(params):
|
||||||
response = basic_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"]:
|
for i in response["entries"]:
|
||||||
contextid = i["@id"]
|
contextid = i["@id"]
|
||||||
polValue = random()
|
random.seed(str(params))
|
||||||
if polValue > 0.5:
|
polValue = 2*random.random()-1
|
||||||
|
if polValue > 0:
|
||||||
pol = "marl:Positive"
|
pol = "marl:Positive"
|
||||||
elif polValue == 0.5:
|
elif polValue == 0:
|
||||||
pol = "marl:Neutral"
|
pol = "marl:Neutral"
|
||||||
else:
|
else:
|
||||||
pol = "marl:Negative"
|
pol = "marl:Negative"
|
||||||
|
Loading…
Reference in New Issue
Block a user