Commit 680f94a4 authored by J. Fernando Sánchez's avatar J. Fernando Sánchez
Browse files

First version for PyPi

parent 3524f572
......@@ -15,7 +15,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
Simple Sentiment Analysis server for EUROSENTIMENT
Simple Sentiment Analysis server
from flask import Blueprint, render_template, request, jsonify, current_app
import config
......@@ -42,6 +42,9 @@ PARAMS = {"input": {"aliases": ["i", "input"],
"required": False,
"options": ["json-ld"],
"algorithm": {"aliases": ["algorithm", "a"],
"required": False,
"language": {"aliases": ["language", "l"],
"required": False,
"options": ["es", "en"],
* Method: POST
* Parameters: JSON Object (that is copied to the result)
* text
* query
* language
* topic
* Example response:
{"data": [{"text": "I love Titanic.", "id":1234, "polarity": 4},
{"text": "I hate Titanic.", "id":4567, "polarity": 0}]}
import requests
import json
def analyse(texts):
parameters = {"data": []}
if isinstance(texts, list):
for text in texts:
parameters["data"].append({"text": text})
parameters["data"].append({"text": texts})
res =, json.dumps(parameters))
return res.json()
def test():
print analyse("I love Titanic")
print analyse(["I love Titanic", "I hate Titanic"])
if __name__ == "__main__":
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment