5 Top APIs For Sentiment Analysis Kelsey Foster December 15, 2021 Advances in deep learning and AI research have brought forth impressive analytic capabilities for spoken and written text across a wide range of industries. In this article, we’ll look at one of these text analysis features — sentiment analysis — and some of the top APIs that offer this service. What is Sentiment Analysis? Sentiment Analysis is a sub-field of Natural Language Processing used to detect the sentiment or feeling of specific text segments. Sentiment can also be detected from an audio or video file, but it requires the file to be transcribed before performing sentiment analysis. This is also sometimes called sentiment mining. Typically, a model will output three possible sentiments: positive, neutral, or negative. However, research in deep learning is currently being done to expand this to a more nuanced scale of emotions and include a broader range of descriptors such as enthusiastic, horrified, thrilled, and others. So, how does sentiment analysis work? Most models work one of two ways. One way is to take written text or transcription text and produce a positive, neutral, or negative output on a 1 to -1 scale. This is also called sentiment polarity. The model will then match the number, say .06, to its closest sentiment, with: 1 = positive 0 = neutral -1 = negative .06 is closest to 0, so it would be considered neutral. Another method is to use probability to designate sentiments. Based on multiclass classification, this model assigns a certainty probability, say 30% positive, 50% neutral, 20% negative. The highest probability sentiment, here neutral, would then be set by the model. Now, what can you do with sentiment analysis? Companies in customer service (call centers, chatbots) use sentiment analysis to analyze customer-agent interactions, categorize conversations, and track customer feelings toward products, services, agents, and more. Companies who use virtual meetings often use sentiment analysis to track participant sentiment by topic, meeting time, or speaker. Then, these companies can use these sentiment analytics to alter marketing strategies, tweak products, train agents, or draft communications. Really, any company with audio, video, or text documentation of interpersonal communications can benefit greatly from sentiment analysis. Top APIs For Sentiment Analysis If you’re in the market for sentiment analysis, here are today’s top APIs for sentiment analysis: 1. Amazon Comprehend for AWS Transcribe AWS Transcribe is Amazon’s Speech-to-Text API with features such as customer conversation insights, media content analysis, subtitles and meeting notes, and more. It also has more niche applications like Amazon Transcribe Medical, which is HIPAA-eligible and trained on medical terminology to improve clinical documentation. AWS Transcribe offers Amazon Comprehend as an add-on API to perform Sentiment Analysis. Using the sentiments tab, Amazon Comprehend can rate your text segments as positive, negative, neutral, or mixed. You’ll also receive a confidence probability rating for each ascribed sentiment. The sentiment analysis is displayed below: { "SentimentScore": { "Mixed": 0.030585512690246105, "Positive": 0.94992071056365967, "Neutral": 0.0141543131828308, "Negative": 0.00893945890665054 }, "Sentiment": "POSITIVE", "LanguageCode": "en" } With, SentimentScore = The level of confidence for each sentiment Sentiment = Ascribed sentiment LanguageCode = Language of transcription text 2. AssemblyAI AssemblyAI is a Speech-to-Text API that offers features such as Automatic Punctuation and Casing, Sentiment Analysis, Word Timings, Paragraph Detection, PII Redaction, and more in addition to asynchronous and real-time transcription. Sentiment Analysis is one of its newer features, recently released in November 2021 and designed with the latest Deep Learning research. When you run your audio or video stream through AssemblyAI, you’ll get an output that looks like this: { "id": "5551722-f677-48a6-9287-39c0aafd9ac1", "status": "completed", "text": "...", "words": [...], # sentiment analysis results are below "sentiment_analysis_results":[ { "text": "Speaking of being in a shadow, didn't you feel yourself in the shadow of those Hollywood A-listers?", "start": 106090, "end": 112806, "sentiment": "NEUTRAL", "confidence": 0.5466495752334595, "speaker": null }, { "text": "It's my privilege to work with these actors.", "start": 114790, "end": 116994, "sentiment": "POSITIVE", "confidence": 0.9224883317947388, "speaker": null }, ... ] } With, Text = The text segment being measured Start/End = Starting and ending timestamps for the text segment Sentiment = Categorized as POSITIVE, NEGATIVE, or NEUTRAL Confidence = Confidence score for assigned sentiment Speaker = If assigned, as through Speaker Diarization 3. Google Cloud Natural Language API for Google Speech-to-Text Google Speech-to-Text is a well-known speech transcription API that supports over 60 distinct languages (over 125 with dialects). Like AssemblyAI, the API offers both real-time and asynchronous transcription with additional features such as Content Filtering, Transcript Evaluation, Sentiment Analysis, Automatic Punctuation, and Speaker Diarization. You can perform sentiment analysis using the Google Cloud Natural Language API. With the API, Google designates a speaker’s sentiment as positive, negative, or neutral as performed through its analyzeSentiment method. When using the Sentiment Analysis feature, your output will look like this: { "documentSentiment": { "magnitude": 0.8, "score": 0.8 }, "language": "en", "sentences": [ { "text": { "content": "Enjoy your vacation!", "beginOffset": 0 }, "sentiment": { "magnitude": 0.8, "score": 0.8 } } ] } With, Score = Overall emotion of the text Magnitude = How much emotional content is present 4. Watson Natural Language Understanding IBM Watson’s Natural Language Understanding API can detect entities, categories, classifications, concepts, emotions, sentiments, relations, metadata, and semantic roles in transcription text with varying accuracy. For sentiment analysis, you can choose to analyze either the sentiments in detected entities or in keywords. Then, a score is assigned, and then the appropriate sentiment is assigned. Here is an example output: { "documentSentiment": { "magnitude": 0.8, "score": 0.8 }, "language": "en", "sentences": [ { "text": { "content": "Enjoy your vacation!", "beginOffset": 0 }, "sentiment": { "magnitude": 0.8, "score": 0.8 } } ] } With, Sentiment.document = whether to return to document level for Sentiment Analysis Sentiment.model = Enter a custom model ID to override the standard sentiment model Sentiment.target = Target strings, separated by commas In addition to Sentiment Analysis, the Natural Language Understanding API also offers Emotion Analysis that detects anger, disgust, fear, joy, or sadness in a text segment. 5. Twinword Sentiment Analysis API Twinword offers text analysis APIs for Word Associations, Sentiment Analysis, Text Similarity, and Emotion Analysis with either a la carte or bundled pricing. Twinword’s Sentiment Analysis API uses scores and ratios to determine its type response of positive, negative, or neutral. Anything that scores below -.05 is considered negative, and anything above .05 is positive, with anything in between neutral. To determine the ratio, the API combines the total score of negative words compared to the total score of positive words, still on a -1 to 1 scale. This ratio helps users better analyze the overall sentiment of texts. See the example below: { "type": "positive", "score": 0.375758241, "ratio": 1, "keywords": [ { "word": "great", "score": 0.797954407 }, { "word": "price", "score": 0.289701948 }, { "word": "value", "score": 0.263316882 }, { "word": "range", "score": 0.152059727 } ], "version": "7.0.8", "author": "twinword inc.", "email": "help@twinword.com", "result_code": "200", "result_msg": "Success" } With, Type = Sentiment Score = Overall emotion of text segment Ratio = Emotion of overall text Keywords = Text analyzed Choosing the Right API for Sentiment Analysis The best APIs for sentiment analysis are built on extensive deep learning research and industry-best principles. If you’re looking to decide between the five APIs described above, here are a few key points of comparison to help: If you have a large budget or already use Amazon S3 Cloud Storage, try Amazon Comprehend. If you have other speech transcription needs and are more budget-conscious, try AssemblyAI. Google Cloud Natural Language is the option for you if you need to analyze a language other than English. Watson Natural Language Understanding can help detect a broader range of emotions, so choose this option if that is important to you. If you just need sentiment analysis with no additional features, Twinword Sentiment Analysis will work great for you. Also, be sure to review available documentation and any changelogs that indicate how often the sentiment analysis feature, and others, are updated. AI services based on the latest research and insights are most likely to ensure continued accuracy and ease of use. The latest API insights straight to your inbox