Code Implementation - Twitter Sentimental Analysis using webMethods
Tags: api, apigateway, integration, sentimentanalysis
Published: 2023-02-10 15:22:25

---
title: Code Implementation - Twitter Sentimental Analysis using webMethods
published: true
date: 2023-01-24 05:42:17 UTC
tags: api, apigateway, integration,sentimentanalysis
canonical_url: https://tech.forums.softwareag.com/t/code-implementation-twitter-sentimental-analysis-using-webmethods/268495
---

## **Twitter Sentiment Analysis using webMethods**

### **Introduction**

The Twitter Sentiment Analysis using webMethods is implemented using functionality which can be re-used like:

- Twitter API Integration
- Azure Sentiment Analysis
- Pie Chart generation
- Word Cloud generation
- Azure Blob Storage Integration
- HTML to PDF Conversion
- PDF Digital signature

Details of each of these implementations are summarized below.

### **Twitter API Integration**

Uses Twitter Search Tweet API to retrieve activity based on username, like:

1. Tweets/Posts made by user
2. Tweets liked by user, number of retweets
3. People followed by the user
4. Tweets/Posts made by the people being followed
5. Capable to stream the tweets in real time based on dynamic filter criteria and pass them as events for continuous processing

This API needs a Twitter developer account. The bearer token associated with the account must be passed in the code to access the APIs.

### **Azure Sentiment Analysis**

This takes the Twitter results as input, utilizes Azure cognitive assessment service to return a Social Sentiment summary as Positive, Negative and Neutral segments.

It also returns the top “n” tweets which are contributing to Positive, Negative and Neutral share.

This needs Azure account with subscription to the Sentiment Analysis service.

### **Pie Chart Generation**

The need to generate a 2D Pie Chart is also implemented which uses Quickchart API.

In this case, it takes the positive, negative and neutral sentiment to generate the chart, but can be enhanced and even customized as per need.

No subscription is needed to invoke this API.

### **Word Cloud Generation**

This service generates a word cloud image using provided Text.  
Most frequently occurring words are shown as bigger text size depending on frequency.

No subscription is needed to invoke this API.

### **Azure Blob Storage**

We have also implemented API to store and retrieve information from Azure Blob container.  
Currently all the processing is being done in-memory as the size of objects is insignificant, but can be enhanced to support streaming for bigger payload sizes.

This requires Azure Storage account and a blob container to be created.

### **HTML to PDF Conversion**

This service generates a PDF report using HTML text as input.  
It also supports styling using CSS, but does not support any Javascript.

### **PDF Digital signature**

To apply digital signature to an existing PDF document.  
It needs location of certificate in PFX format containing private key and its password to do the signing.

### **Packages**

Twitter API Integration can be found in _SentimentAnalysisTwitter_ package.

Azure Social Sentiment analysis can be found in _SentimentAnalysisCognitive_ package.

These implementations can be found in _SentimentAnalysisCommon_ package.

- Pie Chart generation
- Word Cloud generation
- Azure Blob Storage Integration
- HTML to PDF Conversion
- PDF Digital signature

### **SoftwareAG GitHub**

The code is available at:  
[https://github.softwareag.com/PS/sentiment-analysis-twitter-azure.git](https://github.softwareag.com/PS/sentiment-analysis-twitter-azure.git)


[Read full topic](https://tech.forums.softwareag.com/t/code-implementation-twitter-sentimental-analysis-using-webmethods/268495)