This site contains the documentation that is relevant to older WSO2 product versions and offerings.
For the latest WSO2 documentation, go to https://wso2.com/documentation/.

Sentiment Extension

Sentiment Analysis refers to the process of determining whether a piece of writing is positive, negative or neutral. It is also known as opinion mining, deriving the opinion or deriving the attitude of a given text.

Sentiment function

Syntax<int> sentiment:getRate(<string> text)
Extension TypeFunction
DescriptionThe sentiment:getRate is applied to some text in string format to obtain a rating as to whether it is positive, negative or neutral.
Parameters 
Example

sentiment:getRate(“"What is wrong with these people") returns -2.

e.g., An event stream is defined as follows.

define stream inputStream (text string);

The sentiment extension can be used as follows.

from inputStream

select sentiment:getRate(text) as isRate

insert into outputStream;

Here, the input is the input sentence in STRING format. The output is an integer determining the positive or negative aspect of the sentence.