We’ve had many requests from the indico community to add multilingual support for our APIs, so we’ve spent the past few months working on just that. We’re thrilled that we’ve got such a large international following, and we’re always striving to improve our tools to suit your needs. So here’s the big news: our Sentiment Analysis and Keywords APIs now support several major languages! Let’s take a look.

Note: I’m going to use Python for the following examples, but we also have language wrappers in Ruby, node, Java, R and PHP. Otherwise, you can also make calls to one of our RESTful endpoints.


Multilingual Sentiment Analysis

Our Sentiment Analysis API (optimized for speed) now supports these languages:

  • Arabic (ar)
  • Chinese (ch)
  • Dutch (nl)
  • English (en)
  • French (fr)
  • German (de)
  • Italian (it)
  • Japanese (ja)
  • Korean (ko)
  • Portuguese (pt)
  • Russian (ru)
  • Spanish (es)

Note: Sentiment_HQ does not yet support multilingual analysis. We’re working on it!

Here’s how it works — as always, we like to keep it simple:

import indicoio
indico.config.api_key="YOUR_API_KEY"

indicoio.sentiment("你的小猫真的很可爱!", language="chinese")

# returned results
0.8411040270608195

If you’d rather not type the full language name, you can always just use the language code if you know it (it’s standard):

indicoio.sentiment("你的小猫真的很可爱!", language="ch")

If you want to find the sentiment for a piece of text but don’t know what language it’s in, you just can use detect and our Language Detection API will figure it out for you!

import indicoio
indico.config.api_key="YOUR_API_KEY"

indicoio.sentiment("你的小猫真的很可爱!", language="detect")

# returned results
0.8411040270608195

Multilingual Keywords

Our Keywords API now supports these languages:

  • Basque (eu)
  • Bulgarian (bg)
  • Catalan (ca)
  • Czech (cs)
  • Dutch (nl)
  • English (en)
  • French (fr)
  • German (de)
  • Hungarian (hu)
  • Indonesian (id)
  • Italian (it)
  • Japanese (ja)
  • Korean (ko)
  • Polish (pl)
  • Portuguese (pt)
  • Russian (ru)
  • Spanish (es)
  • Turkish (tr)

Here’s some example code to help you get started:

import indicoio
indico.config.api_key="YOUR_API_KEY"

indicoio.keywords("Nous mangeons le dîner à côté du parc.", language="french")

# returned results
{u'nous': 0.39639174760063406, u'parc': 0.34639326989067326, u'mangeons': 0.8437563112129892}

Again, if don’t want to type out the full language name, you can use its standard language code instead:

indicoio.keywords("Nous mangeons le dîner à côté du parc.", language="fr")

Want to analyze the sentiment of a piece of text but not sure which language it’s in? Use detect and let our Language Detection API figure it out for you!

import indicoio
indico.config.api_key="YOUR_API_KEY"

indicoio.keywords("Nous mangeons le dîner à côté du parc.", language="detect")

# returned results
{u'nous': 0.39639174760063406, u'parc': 0.34639326989067326, u'mangeons': 0.8437563112129892}

If you don’t see your language on either of those lists, we’re sorry! We’re working on adding more languages to all our APIs but finding good training data takes time (and sometimes there might not be any available to us). As soon as we add new languages, we’ll be sure to let you know. And, as always, please keep sending us your feedback or suggestions on how we can continue to improve our tools for you. We’ll try our hardest to build it!

Suggested Posts

Is Artificial Intelligence Within Reach?

How to Visualize Email Sentiment with Python

Semi-supervised Feature Transfer: The Practical Benefit of Deep Learning Today?