Tag Archives: mashape

Fuxi API 1.4 released

We are pleased to announce the 1.4 release of the Chinese sentiment analysis Fuxi API. In this release we improved the detection quality a lot. Feel free to send us your feedback. Remember, that on-premise installations are also possible and the API is very lightweight in terms of memory and CPU consumption. 40+ companies and individuals already trust Fuxi API, we will be more than happy to see you on board!

Enjoy 1.4 release of Fuxi #api for #Chinese#sentiment #analysis on Mashape https://market.mashape.com/dmitrykey/fuxiapi and RapidAPI: https://rapidapi.com/user/dmitrykey/package/FuxiAPI

Finding sentiment in Ruby

Dialogue is the largest conference on computational linguistics in Russia. Historically, it has been supported by Abbyy, Yandex, Moscow State University as well as the Higher School of Economics and the Moscow Institute of Physics and Technology. This year, as part of the conference the sentiment analysis track is held. In this post we will show the training / test formats of tweets and illustrate how they can be analyzed with our RSA API in ruby.

The code in this post is using mashape key token that can be obtained by registering a user account on http://market.mashape.com/. After registering, signup for the freemium plan of the RSA API. Then you will have a token that is uniquely identifying your access to this exact API under this exact subscription plan.

 

The training and test data provided by the sentiment track organizers is the following, illustrating with a single tweet text: “Отказ от повышения налогов сохранит и даже ускорит рост ВВП РФ – Sberbank CIB.”

  
      <table name="bank_train_2016">
            <column name="id">70</column>
            <column name="twitid">492546512652500000</column>
            <column name="date">1406267214</column>
            <column name="text">Отказ от повышения налогов сохранит и даже ускорит рост ВВП РФ - Sberbank CIB</column>
            <column name="sberbank">1</column>
            <column name="vtb">NULL</column>
            <column name="gazprom">NULL</column>
            <column name="alfabank">NULL</column>
            <column name="bankmoskvy">NULL</column>
            <column name="raiffeisen">NULL</column>
            <column name="uralsib">NULL</column>
            <column name="rshb">NULL</column>
        </table>

The task is to analyze for sentiment entries in xml tags with name “text” and update target bank name entity with -1 (NEGATIVE), 0 (NEUTRAL) or 1 (POSITIVE) flag.

The following is the code that reads an xml file from the first command line parameter, type of entities from the second parameter (banks or telecom) and updates the input file with automatically calculated sentiment values using the RSA API.

    
require 'rubygems' 
require 'nokogiri'
require 'unirest'

if ARGV.length < 2
    puts "Need xml file as input and type of entities: banks or telecom"
    exit
end


supported_entities = ['banks', 'telecom']
supported_entities_telecom = ['beeline', 'mts', 'megafon', 'tele2', 'rostelecom', 'komstar', 'skylink']
supported_entities_banks   = ['sberbank', 'vtb', 'gazprom', 'alfabank', 'bankmoskvy', 'raiffeisen', 'uralsib', 'rshb']

entities_type = ARGV[1]
if not supported_entities.include?(entities_type)
  puts "Unsupported entities type requested. Supported once are: " + supported_entities.to_s
  exit
end

if entities_type == 'banks'
  target_entities = supported_entities_banks
elsif entities_type == 'telecom'
  target_entities = supported_entities_telecom
else
  puts "FATAL ERROR: request unsupported entities type: " + entities_type
  exit
end


def get_sentiment(text)
  # These code snippets use an open-source library.
  response = Unirest.post "https://russiansentimentanalyzer.p.mashape.com/rsa/sentiment/polarity/json/",
    headers:{
    "X-Mashape-Key" => "[INSERT_TOKEN_HERE]",
    "Content-Type" => "application/json",
    "Accept" => "text/plain"
    },
    parameters: { :text => text, :object_keywords => "", :output_format => "" }.to_json

  puts "get_sentiment, text=" + text + " SENTIMENT=" + response.body["sentiment"]

  if response.body['sentiment'] == "POSITIVE"
    return 1
  elsif response.body['sentiment'] == "NEGATIVE"
    return -1
  else
    return 0
  end
end


file_name = ARGV[0]
@doc = Nokogiri::XML(File.open(file_name))
columns = @doc.xpath("//database/table/column")
sentiment_tag = -2
columns.each { |column| 
     if column['name'] == 'text'
         sentiment_tag = get_sentiment(column.content)
     end
     
     if target_entities.include?(column['name'])
         if sentiment_tag > -2 and column.content != 'NULL'
           puts "updating " +  column['name'] + " with " + sentiment_tag.to_s
           column.content = sentiment_tag
           sentiment_tag = -2
         end
     end
}

File.open(file_name, 'w') {|f| f.write(@doc) }

Annotating sentiment with RussianSentimentAnalyzer API in Java

Hello!

In this post we will show how easy it is to start using RussianSentimentAnalyzer API on mashape from your Java code.

package com.semanticanalyzer;

import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.JsonNode;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;

public class RussianSentimentAnalyzerMashapeClient {

    private final static String mashapeKey = "[PUT_YOUR_MASHAPE_KEY_HERE]";

    public static void main(String[] args) throws UnirestException {

        String textToAnnotate = "'ВТБ кстати неплохой банк)'";
        String targetObject = "'ВТБ'";

        // These code snippets use an open-source library. http://unirest.io/java
        HttpResponse response = Unirest.post("https://russiansentimentanalyzer.p.mashape.com/rsa/sentiment/polarity/json/")
                .header("X-Mashape-Key", mashapeKey)
                .header("Content-Type", "application/json")
                .header("Accept", "application/json")
                .body("{'text':" + textToAnnotate + ",'object_keywords':" + targetObject + ",'output_format':'json'}")
                .asJson();

        System.out.println("Input text = " + textToAnnotate + "\n" + "Target object:" + targetObject);
        System.out.println("RussianSentimentAnalyzer response:" + response.getBody().toString());
    }
}

In the code snippet above we’ve used the mashape’s Unirest API, that makes HTTP requesting in Java super easy.

All you really need to care about is to register at mashape.com, sign up for RussianSentimentAnalyzer API and insert your unique mashape key into the code, in place of “PUT_YOUR_MASHAPE_KEY_HERE”, as a value of the mashapeKey variable.

If everything has been set right, execute the code and you should see the following output:

Input text = 'ВТБ кстати неплохой банк)'
Target object:'ВТБ'
RussianSentimentAnalyzer response:{"sentiment":"POSITIVE","synonyms":"[ВТБ]"}

Now you can easily hook the API up into your cool Java app and annotate texts in Russian for sentiment!

You’ll find the code on our github here: https://github.com/semanticanalyzer/nlproc_sdk_sample_code

Keep calm and use an API

Sentiment detection for English: cheaper prices for even more benefit

At SemanticAnalyzer we believe natural language processing APIs should become a commodity. In a good sense. Every developer should be able to afford integrating AI into their cool mobile and web applications.

So we decided to substantially lower the prices for our English sentiment detection API SentiFindr. New prices you will find here:

https://www.mashape.com/dmitrykey/sentifindr/pricing

We always welcome your feedback. Integrate now for free and tell us what you think! Just raise a ticket anytime: https://www.mashape.com/dmitrykey/sentifindr/support

 

… and: Keep calm and use an API;

Bridge in Helsinki

 

RussianSentimentAnalyzer: API на mashape

анализ тональности

В предыдущем посте мы аннонсировали API анализатора тональности на русском языке. API находится в стадии тестирования по приглашению. Для того чтобы получить приглашение, нужно зарегистрироваться на https://www.mashape.com и скинуть Ваш user id на почту: info[at]semanticanalyzer.info.

К API прилагается документация, а также примеры интеграции на Java, Node, PHP, Python, Objective-C, Ruby и .NET.

RussianSentimentAnalyzer API