X, Y .
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 = "_MASHAPE_KEY_"; 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/ru/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()); } }
Input text = ' )' Target object: '' RussianSentimentAnalyzer response:{"sentiment":"POSITIVE","synonyms":"[]"}
Source: https://habr.com/ru/post/262213/
All Articles