Analyze Text

analyzeText.predict(data, [params])
Make calls to many APIs in parallel.

Arguments

data – String | List – required – text to be analyzed
apis – List – required – the list of APIs to run in parallel
[api_key] – String – optional – your indico API key
[cloud] – String – optional – your private cloud subdomain

Output

A dictionary where each key maps to the specified models’ results. If used on a single input (not recommemnded as using multiple APIs quickly uses up your allotted calls!) you’ll get the default response, otherwise a list of the default.

# single output
{
    'sentiment_hq': 0.7300551533699036,
    'political': {
        'Conservative': 0.2288717527904388,
        'Green': 0.05575739681227337,
        'Liberal': 0.6541234047231098,
        'Libertarian': 0.06124744567417795
    }
}

# batch output
{
    "political": [
        {
            'Conservative': 0.2288717527904388,
            'Green': 0.05575739681227337,
            'Liberal': 0.6541234047231098,
            'Libertarian': 0.06124744567417795
        },
        {
            'Conservative': 0.2288717527904388,
            'Green': 0.05575739681227337,
            'Liberal': 0.6541234047231098,
            'Libertarian': 0.06124744567417795
        }
    ], 
    "sentiment_hq": [0.7300551533699036]
}

Example

import io.indico.Indico;
import io.indico.api.IndicoResult;
import io.indico.api.BatchIndicoResult;

Map<String, Object> params = new HashMap<>()
ArrayList apiList = new ArrayList();
apiList.add("sentiment_hq");
apiList.add("political");
params.put("apis", apiList);

Indico indico = new Indico("YOUR_API_KEY");

// single example
IndicoResult single  = indico.text.predict(
    "Democratic candidate Hillary Clinton is excited for the upcoming election.",
    params
);
Double result = single.getSentimentHQ();
System.out.println(result);

// batch example
String[] example = {
    "Democratic candidate Hillary Clinton is excited for the upcoming election.", 
    "Bill Clinton joins President Obama for a birthday golf game at Marthas Vineyard."
};

BatchIndicoResult multiple = indico.text.predict(
    example,
    params
);
List result = multiple.getSentimentHQ();
System.out.println(result);