Text Analytics Connector Example

<< Click to Display Table of Contents >>

Navigation:  Bizagi Studio > Integrating external applications from Bizagi > Artificial Intelligence Connectors > Using Microsoft Cognitive Services from Bizagi >

Text Analytics Connector Example

Suppose the following process is how customer reviews are handled in your company's Customer Satisfaction area.

 

TextAnalytics02

 

After the area receives a review, it is analyzed using the Text Analytics powered by Microsoft Cognitive Services connector. Depending on the review's sentiment score, different actions are taken into place:

When it is a positive review, the involved parties receive the positive feedback.

When the review is negative, the involved parties identify the improvement opportunities based on the review.

When the sentiment is neutral or mixed, the review is then analyzed by a person who will classify the review as either positive or negative.

 

This is the data model for the Review Analysis process:

 

TextAnalytics02b

 

This process uses different methods to analyze the reviews: starting with language recognition and then identifying the review's sentiment. If the review is neutral, key phrases will be extracted to make the manual analysis easier.

 

Keep in mind that every time you use the connector you can either add the response to the Analyzed Reviews collection or overwrite the collection. In this case the recommended setup is to have all the requests in the response collection (Analyzed Reviews). The Documents entity has the Content attribute, you can use this attribute to tell the responses apart. Also keep in mind that there is only one review per process, this means that you'll receive one collection item per connector use. The analyzed reviews collection will not exceed three items, which is the maximum number of times the connector can be used in the process.

 

The actions that are executed on enter of the Analyze Review service task are as follows:

 

TextAnalytics05

 

First, the Text Analytics connector is used to detect the review's language, this is how the response should be mapped to identify it as part of the language detection action. Notice that there is a constant String with the value Language Detection mapped to Content attribute of the collection item.

 

TextAnalytics06

 

Next, there is a rule that obtain the language response and assigns it as the review's language.

 

TextAnalytics07

 

The expression code is as follows:

//Obtain response collection

var cAnalyzedDocs = Me.getXPath("ReviewAnalysis.AnalyzedReviews");

 

//Obtain the detected languages collection from the first collection item

var cLanguage = cAnalyzedDocs.get(0).getXPath("DetectedLanguages");

 

//Extract the ISO6391 Name

var sShortLanguage = cLanguage.get(0).getXPath("ISO6391Name");

 

//Set language value for the review

var cReviews = Me.getXPath("ReviewAnalysis.Review");

cReviews.get(0).setXPath("TextLanguage",sShortLanguage);

 

The third action in this task is to detect the sentiment of the review, this is how the response should be mapped to identify it as part of the sentiment detection action. Notice that there is a constant String with the value Sentiment Detection mapped to Content attribute of the collection item.

 

TextAnalytics08

 

The Sentiment method returns the sentiment along with the each of sentiment scores for positivity, negativity and neutrality. The sentiment score values the certainty of the detected sentiment, values closer to 1 represent a higher certainty. Take advantage of these values when setting up the exclusive gateway.

 

Before setting up the gateway, you must map the results from the collection item received from the Sentiment method as values in the Process Entity. You can do this mapping by running an expression as an On Enter action for the exclusive gateway.

 

TextAnalytics04

 

The expression code is as follows:

//Get the sentiment response item

var cAnalysis= Me.getXPath("ReviewAnalysis.AnalyzedReviews");

var analysis = cAnalysis.get(1);

 

//Set values for Process entity

<ReviewAnalysis.PositiveScore> = analysis.getXPath("DocumentScore.positive");

<ReviewAnalysis.NeutralScore>  = analysis.getXPath("DocumentScore.neutral");

<ReviewAnalysis.NegativeScore> = analysis.getXPath("DocumentScore.negative");

 

//Set Review sentiment

var cReview= Me.getXPath("ReviewAnalysis.Review");

var sSentiment = analysis.getXPath("Sentiment");

cReview.get(0).setXPath("Sentiment", sSentiment);

 

After setting up our connector, set up the exclusive gateway with the sentiment scores for the text.

In this example 0.6 is used as a threshold value for defining whether the review was positive or negative. This way, when the review has a positive score over 0.6, it is interpreted as a positive review. When the negative score is over 0.6, it is interpreted as a negative review and when neither of those scores are reached, the review is interpreted as neutral and is sent over for manual analysis.

 

TextAnalytics03

 

When the sentiment is mixed, this is how the response should be mapped to identify it as part of the Set Key Phrases service task. Notice that there is a constant String with the value Key Phrases mapped to Content attribute of the collection item.

 

TextAnalytics09

 

With this set up, when a review is classified as neutral the final user will be able to tell the responses from one another in the Manually Analyze Text task. The task's form shows the review, along with the identified sentiment, languages and the sentiment score.

 

TextAnalytics10

 

When the user selects an analysis result and views the detail form, depending on the action, the form displays different information.

 

This is an example of the language detection results:

 

TextAnalytics11

 

The user sees the language name, the short name (ISO6391) and the certainty score of the detection.

 

When the user views the details for the sentiment detection, they will see something like this:

 

TextAnalytics12

 

The overall text sentiment is displayed along with the sentiment and scores for each sentence. The offset attribute refers to the position of the sentence in the analyzed text and the length attribute refers to the sentence's length in characters.

 

The user can also view the detected key phrases, the detail form looks like this:

 

TextAnalytics13

 

These phrases may be useful to identify the main text ideas and the sentiment.

 

The user can then decide, with this information obtained though Microsoft Cognitive services, whether the review is positive or negative and continue with the process.