Sentiment analysis is the application of natural language processing to determine whether a given text conveys either positive, negative, or neutral sentiment. It is also known as opinion mining. This kind of data combined with analytics can be used to determine product affinity in the market, mass opinion on the certain topic (especially on twitter data), or can be leveraged by customer support services to identify and improve the experience. In our application in chatbots, when user enters a query mentioning all search criteria, we extract the words indicating search feature, and use them to form search query. But we need to know the attitude of user towards these search criteria to avoid giving wrong results. We use sentiment analysis to do this.
In the first query, user mentions features which he wants or does not want in a house.
In second user query, he changes the search criteria because he does not like the results. This can be achieved by using sentiment analysis to detect user attitude towards various house features. This sentiment data can be combined other text features like the word vector and intent to train machine learning model.
There are various technique for sentiment analysis, you can view these here Sentiment analysis algorithms and applications: A survey
In our application, we explored the tree lstm and Stanford sentiment analysis in the coreNLP package. The Stanford’s sentiment analysis is also based on tree lstm.
Tree LSTM model
The tree lstm model was proposed by Richard Socher et al. The model is based on the Recursive neural network. The Recursive neural network works by recursively applying same weight on input, forming a hierarchical structure. Recurrent neural network work by applying same weights in linear order over input and are therefore considered a variant of the Recursive neural network. Both are confusingly abbreviated as RNN. When we use lstm gating mechanism to preserve the gradient we call it the tree lstm model.
The input needs to be fed in form of dependency tree. When we train this kind of model it learns to detect sentiment of words and phrases which are formed by these words which at end form the final sentence.
Text can be converted to tree using Stanford dependency parser. The Stanford sentiment treebank provides the statement, their parsed forms and labels. The network can be constructed using tensorflow or pytorch. The Stanford coreNLP package also has an implementation of sentiment analysis.
To learn more about Botsplash click the button below to schedule a demo with our team.