Analyze Text

analyzeText(data, {apis: List, [apiKey]: String, [privateCloud]: String})
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
[apiKey] – String – optional – your indico API key
[privateCloud] – 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

var indico = require('indico.io');
indico.apiKey =  'YOUR_API_KEY';

var response = function(res) { console.log(res); }
var logError = function(err) { console.log(err); }
  
// single example
indico.analyzeText("Democratic candidate Hillary Clinton is excited for the upcoming election.", {apis: ['sentiment_hq', 'political']})
  .then(response)
  .catch(logError);

// batch example
indico.analyzeText(
    [
        "Democratic candidate Hillary Clinton is excited for the upcoming election.",
        "Bill Clinton joins President Obama for a birthday golf game at Marthas Vineyard."
    ], 
    {apis: ['sentiment_hq', 'political']}
)
.then(response)
.catch(logError);