Analyze Text

analyze_text(data, apis, [api_key], [cloud])
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 indicoio
indicoio.config.api_key = 'YOUR_API_KEY'

# single example
indicoio.analyze_text("Democratic candidate Hillary Clinton is excited for the upcoming election.", apis=['sentiment_hq', 'political'])

# batch example
indicoio.analyze_text(
    [
        "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']
)