Tahir Naveed
Feb 14, 2020
(2 votes)

Using Microsoft cognitive services to improve content sentiments

In this blog post, I will describe how we have utilised Microsoft cognitive services (Text Analytics API) to analyse content before a content author publishes it so it can be rewritten in a more positive tone. The Text Analytics API uses a machine learning classification algorithm to generate a sentiment score between 0 and 1. Scores closer to 1 indicate positive sentiment, while scores closer to 0 indicate negative sentiment.

Content author will be encourged to rewrite content if a score closer to zero is returned - the idea is to make sure our content conveys the message in a postive manner.

A working example can be seen below and all the code is in github.

The basic steps are as follows

  1. Create a Microsoft azure account and subscribe to Microsoft cognitive services. You will need the end point and a key. A detail documentation can be found here
  2. Create a plugin (button) in tinymce
    1. The button when clicked will call a server side web api and pass the tinymce content alongwith via an ajax call.
  3. Create a server side web api controller to process content
    1. This controller will receive the content from tinymce and will call microsoft cognitive services to analyse sentiments of the content

Visual studio solution architecture:

  1. Use visual studio extension to create basic episerver alloy vinealla website.
  2. Install the following nuget packages
    1. install-package Microsoft.AspNet.WebApi
      1. You will need to configure some basic routes ( see the working example)
    2. install-package Microsoft.Azure.CognitiveServices.Language.TextAnalytics
      1. You will need to configure Cognitive services in Azure portal and then copy/paste the key in the sample

Once it is configured, the backend code is all setup.

For front end code, I have utilised yomen TinyMCE Plugin Generator to generate a tinymce plugin. More documentation can found here. Simple code to add a button to tinymce editor which when clicked will made an ajax call to backend web api and show the result to end use.

(Please note the code share is a basic example of making it all work together and it is not production ready code)

Feb 14, 2020


Please login to comment.
Latest blogs
Caching & Rendering of metadata from the DAM

For the EPiServer.Cms.WelcomeIntegration.UI 1.2.0 release, we have facilitated the ability to cache and render metadata from assets within the DAM....

Matthew Slim | Jun 2, 2023

Conversion Rate Optimization: Maximizing ROI through Data-Driven Decisions

In today's digital landscape, businesses are constantly looking for ways to improve their online presence and drive more conversions. One effective...

JessWade | Jun 1, 2023

Enhance Your Writing with Suggestions

Are you tired of staring at a blank screen, struggling to find the right words? The Epicweb.Optimizely.AIAssistant Addon is here to revolutionize...

Luc Gosso (MVP) | May 31, 2023 | Syndicated blog

Content Graph - Letting GraphQL do all the hard work for you

Background As we have seen before, setting up Content Graph on the CMS side is pretty easy. However, when it comes to the “head” part of the setup,...

Kunal Shetye | May 26, 2023 | Syndicated blog