コード例 #1
0
ファイル: app.py プロジェクト: EuroSentiment/flask-endpoint
        contextid = i["@id"]
        random.seed(str(params))
        polValue = 2*random.random()-1
        if polValue > 0:
            pol = "marl:Positive"
        elif polValue == 0:
            pol = "marl:Neutral"
        else:
            pol = "marl:Negative"
        i["opinions"] = [{"marl:polarityValue": polValue,
                          "marl:hasPolarity": pol

                          }]
        i["strings"] = []
        for m in rgx.finditer(i["nif:isString"]):
            i["strings"].append({
                "@id": "{}#char={},{}".format(contextid, m.start(), m.end()),
                "nif:beginIndex": m.start(),
                "nif:endIndex": m.end(),
                "nif:anchorOf": m.group(0)
            })

    return response

app.analyse = hard_analysis
app.register_blueprint(nif_server)

if __name__ == '__main__':
    app.debug = config.DEBUG
    app.run()