About

Millions of opinions, conversations or just trivia are published each day in Social Media by users of different cultures, countries and ages. This provides an effective way to poll how people praise, complain or discuss about virtually any topic. Comprehending and analysing all this information has become a new challenge for organisations and companies, which aim to find out a way to make quick and more effective decisions for their business. In this respect, sentiment analysis, and more specifically polarity classification, is playing an important role in order to automatically analyse subjective information in texts, identifying if the text is positive, negative and neutral for example.

Miopia provides a simple API to identify the sentiment both of Spanish and English messages, giving access to different models that have effectively worked in international evaluations campaigns.

Miopia is intented to work at sentence-level and we encourage you to use it in this way, although you are free to call it to carry out text-level polarity classification.

Miopia is a newborn project and may be "myopic" sometimes, assigning an incorrect polarity. Interactive feedback is supported via our online demo. Bug reports and suggestions are also welcome, contact us.

API v0.1 Reference

Resource Description
POST /polarity/[LANG]/[MODEL]/ Calculates the polarity of a given text written in [LANG] using the specified [MODEL]. Read next section for available languages and models.

Resource: POST /polarity/[LANG]/[MODEL]/

Calculates the polarity of a given text. The granularity of the classification depends on the model.

Languages and Models

[LANG]/[MODEL]
(alias)
Description
es/supervised/
es/tass2014
Spanish language model, developed using supervised learning techniques. Classifies a text into one of 5 categories: P+, P, NONE, N, N-
es/rule-based/
es/nle/
Spanish language model, which uses a syntactic rule-based strategy. Classifies a text into one of 3 categories: positive, none, negative
en/supervised/
en/semeval2014/
English language model, developed using supervised learning techniques. Classifies a text into one of 3 categories: positive, none, negative

Request Format

Headers
Authorization
optional
If an API key is specified, higher request limits will be applied (see FAQs). The format is: Token <MyToken> where <MyToken> is your API token key
Post Data
text
required
Text to be evaluated. As is usual with post data, it must be formatted using application/x-www-form-urlencoded

Response

Responses are in json format, and they specify the polarity of the given text according to the selected model.

If you exceed the maximum number of requests an error message will be returned instead of the polarity. That message will indicate the number of seconds that you should wait before making any further requests:

detailRequest was throttled.Expected available in XX seconds.

Example Request/Response

POSThttp://miopia.grupolys.org/api/v1.0/polarity/es/supervised
HeaderAuthorization: Token f13681c42c01b9e873224279e59818954c539e06
POST Datatext=Me%20gusta%20pero%20es%20caro
Response
{"polarity": "Negative"}

API Client

Command Line

Calling our API from the command line is very easy in *nix environments using curl:
$>curl miopia.grupolys.org/api/v1.0/polarity/en/supervised/ --data-urlencode "text=That was one nice movie last night"

{"polarity": "positive"}
You can specify your API token with the -H option:
$>curl miopia.grupolys.org/api/v1.0/polarity/en/supervised/ -H 'Authorization: Token f13681c42c01b9e873224279e59818954c539e06' --data-urlencode "text=That was one nice movie last night"

{"polarity": "positive"}

Python

A simple python command line client is also available. Its usage is straightforward
usage: miopia_polarity.py [-h] -l LANG -t TEXT [-m MODEL] [-k TOKEN]

optional arguments:
  -h, --help            show this help message and exit
  -l LANG, --lang LANG  Language of the text ('es' or 'en')
  -t TEXT, --text TEXT  Text to be analyzed
  -m MODEL, --model MODEL
                        Optional: Model to use. Defaults to 'supervised' (see
                        http://http://miopia.grupolys.org/docs)
  -k TOKEN, --token TOKEN
                        Optional: API token (obtain one at
                        http://miopia.grupolys.org/)
Download

FAQs

What authentication scheme does the API use?
MIOPIA's REST API uses a simple token based authentication. You can obtain a token by registering an user account.
What are the usage limits for the REST API?
Anonymous users are limited to 1 request/min. Authenticated users are allowed up to 30 requests/min.
Do I have to register in order to use the API?
NO. Registration is not required, but anonymous face a tougher throttling policy than registeded users (see previous question).