Sentiment Analysis of Comment Texts Based On BiLSTM
Sentiment Analysis of Comment Texts Based On BiLSTM
Received March 15, 2019, accepted March 31, 2019, date of publication April 9, 2019, date of current version April 29, 2019.
Digital Object Identifier 10.1109/ACCESS.2019.2909919
ABSTRACT With the rapid development of Internet technology and social networks, a large number
of comment texts are generated on the Web. In the era of big data, mining the emotional tendency of
comments through artificial intelligence technology is helpful for the timely understanding of network public
opinion. The technology of sentiment analysis is a part of artificial intelligence, and its research is very
meaningful for obtaining the sentiment trend of the comments. The essence of sentiment analysis is the text
classification task, and different words have different contributions to classification. In the current sentiment
analysis studies, distributed word representation is mostly used. However, distributed word representation
only considers the semantic information of word, but ignore the sentiment information of the word. In this
paper, an improved word representation method is proposed, which integrates the contribution of sentiment
information into the traditional TF-IDF algorithm and generates weighted word vectors. The weighted word
vectors are input into bidirectional long short term memory (BiLSTM) to capture the context information
effectively, and the comment vectors are better represented. The sentiment tendency of the comment is
obtained by feedforward neural network classifier. Under the same conditions, the proposed sentiment
analysis method is compared with the sentiment analysis methods of RNN, CNN, LSTM, and NB. The
experimental results show that the proposed sentiment analysis method has higher precision, recall, and F1
score. The method is proved to be effective with high accuracy on comments.
INDEX TERMS Sentiment analysis, artificial intelligence, social network, weighted word vectors, BiLSTM.
2169-3536 2019 IEEE. Translations and content mining are permitted for academic research only.
51522 Personal use is also permitted, but republication/redistribution requires IEEE permission. VOLUME 7, 2019
See http://www.ieee.org/publications_standards/publications/rights/index.html for more information.
G. Xu et al.: Sentiment Analysis of Comment Texts Based on BiLSTM
word vectors do not contain sentiment information about analysis model based on SVM was proposed. Sentiment anal-
words. In this paper, the contribution of the word’s sentiment ysis method based on machine learning tends to be more
information to text sentiment classification is embedded into accurate, but it relies on the quality of the corpus labeled with
the traditional TF-IDF algorithm, and the weighted word polarity.
vector is generated. In recent years, many scholars have introduced the method
In this paper, a sentiment analysis method of comments of deep learning into sentiment analysis and achieved good
based on BiLSTM is proposed. The remainder of this article results. The RNTN (Recursive Neural Tensor Network)
consists of four parts. Firstly, the research backgrounds of the model proposed by Socher et al. [18] introduced a senti-
text sentiment analysis method and the representation of the ment tree library, which synthesized semantics on the syn-
word vector are expounded. Secondly, the detail of the pro- tactic tree of binary sentiment polarity and obtained good
posed sentiment analysis method of comments is described. sentiment analysis results in the data set of movie reviews.
Thirdly, the experiments are carried out and the experimental The CharSCNN [19] (Character to Sentence Convolutional
results are analyzed and discussed. Finally, the proposed Neural Network) model used two convolutional layers to
method is summarized and the next research direction is extract the features of related words and sentences, and mined
introduced. semantic information to improve the sentiment analysis of
short texts like Twitter. Irsoy and Cardie [20] used the Recur-
rent Neural Network based on time series information to
II. BACKGROUND obtain sentence representation, which further improved the
A. TEXT SENTIMENT ANALYSIS TECHNOLOGY accuracy of sentiment classification. Ta et al. [21] proposed a
Text sentiment analysis technology mines text emotions Tree-Structured Long Short-Term Memory Networks model,
through computer technology. According to the object of which had achieved good results in semantic association and
sentiment analysis, text sentiment analysis can be divided sentiment classification. Baziotis et al. [22] introduced the
into three levels, respectively for words [7], sentences [8], attention mechanism into the LSTM, which achieved good
chapters [9]. According to the classification method of sen- results in the sentiment analysis of SemEval-2017 Task4 for
timent orientation, it can be divided into binary sentiment Twitter.
classification [10], ternary sentiment classification [11] and Considering that the feature words of comments are sparse,
multi-sentiment classification [12]. and in order to better capture the context information, Bidi-
At present, text sentiment analysis methods are mainly rectional Long Short Term Memory [23] in deep learning is
divided into three categories: sentiment analysis method used to obtain the comment representation in this paper.
based on sentiment dictionary, sentiment analysis
method based on machine learning, and sentiment analysis B. WORD REPRESENTATION
method based on deep learning. In natural language processing, words in sentences or docu-
The method based on sentiment dictionary uses the dic- ments are usually used as features [24]–[26]. Currently, there
tionary to identify sentiment words in the text and obtain are two widely used word vector representations: one-hot
sentiment values. Then, according to the sentiment calcu- representation and distributed representation.
lation rules, the text sentiment tendency is obtained. The The vector dimension of one-hot representation is decided
literatures [13], [14] introduced the representative research by the words’ number of the dictionary containing a large
based on sentiment dictionary. Text sentiment analysis based number of words and is the same as it. The vector of the
on sentiment dictionary does not require manual labeling of word only has a dimension value of 1 corresponding to the
samples and is easy to implement. However, the quality of position of the word in the dictionary, and the rest dimension
the analysis is highly dependent on the sentiment dictionary. values are 0. The method has the following problems: (1) The
Most of the sentiment dictionaries have problems such as vector dimension will be too large if there are too many words
insufficient coverage of sentiment words and lack of domain contained in the dictionary; (2) The vector has too many
words. 0 values, which causes the sparseness of the vector; (3) This
The earliest research on text sentiment analysis based on method ignores the semantic association of the words.
machine learning was Pang et al. [15]. They used naive Distributed representation was proposed by Hinton in the
Bayesian algorithm, maximum entropy algorithm and SVM 1986 [27]. It maps each word into a low-dimensional real
algorithm to analyze the sentiment of film reviews. Finally, vector, which solves the problem that the dimension of the
the experimental results showed that SVM algorithm worked One-hot representation word vector is too large. All word rep-
best in dealing with the sentiment classification of movie resentations constitute a word vector space, so the semantic
reviews. Goldberg and Zhu [16] proposed a graph-based similarity can be judged by calculating the distance between
semi-supervised classification algorithm which scored 0-4 words.
stars for the positive and negative comments. Wang et al. [17] Bengio et al. [28] first introduced word distributed rep-
studied the sentiment analysis of short texts. Based on mul- resentation into the language model of neural network, and
tiple dimensions such as sentiment features, negative fea- proposed the Neural Network Language Model (NNLM).
tures and emoji, a high-dimensional mixed feature sentiment For the NNLM model, the context of the word wt was
paper, the sentiment reinforcement of sentiment word vec- process of obtaining the sentiment polarity of the comment
tor is realized. Sentiment analysis tasks are essentially text text. Among them, NodeNum refers to the number of nodes
categorization tasks, and distributed word vectors do not of LSTM hidden layer.
take into account the contributions of different words to the
categorization task. In Section A of Research Methods, the IV. EXPERIMENT
weighted word vectors containing sentiment information and A. EXPERIMENTAL ENVIRONMENT
classification contribution are constructed. In this paper, the experimental hardware platform is Intel
Firstly, the weighted word vectors are used as the inputs Xeon E5 (6 cores), 32G memory, GTX 1080 Ti. The exper-
of BiLSTM model, and the outputs of BiLSTM model are imental software platform is Ubuntu 16.04 operating system
used as the representations of the comment texts. Then, and development environment is Python3.5 programming
the comment text vectors are input into the feedforward language. The Tensorflow library and the Scikit-learn library
neural network classifier. Finally, the sentiment tendency of of python are used to build the proposed sentiment analysis
the comments is obtained. The activation function of feedfor- method and comparative experiments.
ward neural network is ReLU function. In order to prevent
the over-fitting phenomenon in the training process, dropout B. DATA SET
mechanism was introduced, and dropout discarding rate was The experimental corpus which has equal number of positive
set to 0.5. and negative texts includes 15000 hotel comment texts (Data
The schematic diagram of the sentiment method proposed set) crawled from Ctrip (https://www.ctrip.com/). The polari-
in this paper is as FIGURE 3. The left subgraph is the process ties of the comment texts have been labeled on Ctrip website.
of comment text feature extraction. The right subgraph is the Examples of Data set are shown in Table 3.
3) LEARNING RATE
The appropriate choice of learning rate is important for the
optimization of weights and offsets. If the learning rate is
too large, it is easy to exceed the extreme point, making the
system unstable. If the learning rate is too small, the training
time is too long. FIGURE 6 is the classification effect of the
model at different learning rates.
representation method proposed in this paper takes into TABLE 8. Experimental results of the proposed method and other
traditional methods.
account the sentiment information contained in the words and
the contribution to the classification task, which alleviates the
above problems to some extent.
computation, and a new representation method of word vector [17] Y. Wang, X. Zheng, D. Hou, and W. Hu, ‘‘Short text sentiment classifica-
based on the improved term weight computation is proposed. tion of high dimensional hybrid feature based on SVM,’’ Comput. Technol.
Develop., vol. 28, no. 2, pp. 88–93, Feb. 2018.
In addition, BiLSTM model fully considers the context infor- [18] R. Socher, ‘‘Recursive deep models for semantic compositionality over
mation and can better obtain the text representation of the a sentiment treebank,’’ in Proc. Conf. Empirical Methods Natural Lang.
comments. Finally, through the feedforward neural network Process., Seattle, WA, USA, 2013, pp. 1631–1642.
[19] C. D. Santos and M. Gattit, ‘‘Deep Convolutional Neural Networks for
and softmax mapping, the sentiment tendency of the text is Sentiment Analysis of Short Texts,’’ in Proc. 25th Int. Conf. Comput.
obtained. The experiments of different word representation Linguistics: Tech. Papers, Dublin, Ireland, 2014, pp. 69–78.
methods prove the validity of the proposed word represen- [20] O. Irsoy and C. Cardie, ‘‘Opinion Mining with Deep Recurrent Neural
Networks,’’ in Proc. Conf. Empirical Methods Natural Lang. Process.,
tation method in this paper. Through the comparison exper- Doha, Qatar, 2014, pp. 720–728.
iments with other traditional sentiment analysis methods, [21] K. S. Tai, R. Socher, and C. D. Manning, ‘‘Improved semantic repre-
the accuracy of the proposed comment sentiment analysis sentations from tree-structured long short-term memory networks,’’ in
Proc. 53rd Annu. Meeting Assoc. Comput. Linguistics, China, Aug. 2015,
method is improved. However, the sentiment analysis method pp. 1556–1566.
of comments based on BiLSTM consumes a long time in [22] C. Baziotis, N. Pelekis, and C. Doulkeridis, ‘‘Datastories at SemEval-
the training model. In future work, the method to effectively 2017 Task 4: Deep LSTM with attention for message-level and topic-
based sentiment analysis,’’ in Proc. 11th Int. Workshop Semantic Eval.
accelerate the training process of the model will be studied. (SemEval), Vancouver, BC, Canada, Aug. 2017, pp. 747–754.
[23] F. Zhang, C. Hu, Q. Yin, W. Li, H.-C. Li, and W. Hong, ‘‘Multi-aspect-
REFERENCES aware bidirectional LSTM networks for synthetic aperture radar target
recognition,’’ IEEE Access, vol. 5, pp. 26880–26891, 2017.
[1] L. Wang, D. Miao, and Z. Zhang, ‘‘Emotional analysis on text sentences [24] Y. Liu, W. Song, L. Liu, and H. Wang, ‘‘Document representation based
based on topics,’’ Comput. Sci., vol. 41, no. 3, pp. 32–35, Mar. 2014. on semantic smoothed topic model,’’ in Proc. 17th IEEE/ACIS Int. Conf.
[2] S. Krishnamoorthy, ‘‘Sentiment analysis of financial news articles using Softw. Eng., Artif. Intell., Netw. Parallel/Distrib. Comput., Beijing, China,
performance indicators,’’ Knowl. Inf. Syst., vol. 56, no. 2, pp. 373–394, May/Jun. 2016, pp. 65–69.
Aug. 2018. [25] L. Zhu, G. Wang, and X. Zou, ‘‘A study of chinese document representation
[3] N. Shelke, S. Deshpande, and V. Thakare, ‘‘Domain independent approach and classification with word2vec,’’ in Proc. 9th Int. Symp. Comput. Intell.
for aspect oriented sentiment analysis for product reviews,’’ in Proc. 5th Des., Hangzhou, China, Dec. 2017, pp. 298–302.
Int. Conf. Frontiers Intell. Comput., Theory Appl., Singapore, Mar. 2017, [26] Z. Jianqiang, G. Xiaolin, and Z. Xuejun, ‘‘Deep convolution neu-
pp. 651–659. ral networks for twitter sentiment analysis,’’ IEEE Access, vol. 6,
[4] P. Sharma and N. Mishra, ‘‘Feature level sentiment analysis on movie pp. 23253–23260, 2018.
reviews,’’ in Proc. 2nd Int. Conf. Next Gener. Comput. Technol. (NGCT), [27] G. E. Hinton, ‘‘Learning distributed representations of concepts,’’ in Proc.
Dehradun, India, Oct. 2016, pp. 306–311. 8th Annu. Conf. Cogn. Sci. Soc., vol. 1, Aug. 1986, p. 12.
[5] Q. Zhang, S. Zhang, and Z. Lei, ‘‘Chinese text sentiment classification [28] Y. Bengio, R. Ducharme, P. Vincent, and C. Jauvin, ‘‘A neural probabilis-
based on improved convolutional neural networks,’’ Comput. Eng. Appl., tic language model,’’ J. Mach. Learn. Res., vol. 3, no. 6, pp. 932–938,
vol. 53, no. 22, pp. 111–115, Sep. 2017. Feb. 2003.
[6] D. Zhang et al., ‘‘Chinese comments sentiment classification based on [29] T. Mikolov, I. Sutskever, K. Chen, G. S. Corrado, and J. Dean, ‘‘Dis-
word2vec and SVMperf,’’ Comput. Sci., vol. 42, no. 4, pp. 1857–1836, tributed representations of words and phrases and their compositional-
Oct. 2016. ity,’’ in Proc. Adv. Neural Inf. Process. Syst., Nevada, NV, USA, 2013,
[7] L. Kang, L. Xu, and J. Zhao, ‘‘Co-extracting opinion targets and opinion pp. 3111–3119.
words from Online reviews based on the word alignment model,’’ IEEE [30] Y. Kim, ‘‘Convolutional neural networks for sentence classification,’’ in
Trans. Knowl. Data Eng., vol. 27, no. 3, pp. 636–650, Mar. 2015. Proc. Conf. Empirical Methods Natural Lang. Process., Doha, Qatar,
[8] Z. Hao, R. Cai, Y. Yang, W. Wen, and L. Liang, ‘‘A dynamic conditional Aug. 2014, pp. 1746–1751.
random field based framework for sentence-level sentiment analysis of [31] D. Tang, F. Wei, and B. Qin, N. Yang, T. Liu, and M. Zhou, ‘‘Sentiment
chinese microblog,’’ in Proc. IEEE Int. Conf. Comput. Sci. Eng. (CSE), embeddings with applications to sentiment analysis,’’ IEEE Trans. Knowl.
Guangzhou, China, Jul. 2017, pp. 135–142. Data Eng., vol. 28, no. 2, pp. 496–509, Feb. 2016.
[9] Z. U. Rehman and I. S. Bajwa, ‘‘Lexicon-based sentiment analysis for [32] H. Chen, M. Sun, C. Tu, Y. Lin, and Z. Liu, ‘‘Neural sentiment classifica-
urdu language,’’ in Proc. 6th Int. Conf. Innov. Comput. Technol. (INTECH), tion with user and product attention,’’ in Proc. Conf. Empirical Methods
Dublin, Ireland, Aug. 2016, pp. 497–501. Natural Lang. Process., Austin, TX, USA, 2016, pp. 1650–1659.
[10] A. S. Manek, P. D. Shenoy, M. C. Mohan, and K. R. Venugopal, ‘‘Aspect [33] J. Liu and Z. Zhang, ‘‘Sentiment analysis on food safety news using joint
term extraction for sentiment analysis in large movie reviews using Gini deep neural network model,’’ Comput. Sci., vol. 43, no. 12, pp. 277–280,
Index feature selection method and SVM classifier,’’ World Wide Web, Dec. 2016.
vol. 20, no. 2, pp. 135–154, Mar. 2017. [34] J. Li. Chinese Sentiment Dictionary. Research Institute Information
[11] M. Mubarok, S. Adiwijaya, and M. D. Aldhi, ‘‘Aspect-based sentiment Technology, Tsinghua University, Beijing, China. Accessed: Oct. 4, 2018.
analysis to review products using Naïve Bayes,’’ in Proc. AIP Conf., [Online]. Available: http://nlp.csai.tsinghua.edu.cn/site2/index.php/zh/
Budapest, Hungary, 2017, pp. 1–8. people?catid=13&id=13:v10
[12] M. Bouazizi and T. Ohtsuki, ‘‘A pattern-based approach for multi-class [35] W. A. Shu-heng, T. U. Ibrahim, and K. Abiderexiti, ‘‘Sentiment classfica-
sentiment analysis in twitter,’’ IEEE Access, vol. 5, pp. 20617–20639, tion of Uyghur text based on BLSTM,’’ Comput. Eng. Des., vol. 38, no. 10,
2017. pp. 2879–2886, 2017.
[13] P. Turney and M. L. Littman, ‘‘Measuring praise and criticism: Inference
of semantic orientation from association,’’ ACM Trans. Inf. Syst., vol. 21,
GUIXIAN XU was born in Changchun, Jilin,
no. 4, pp. 315–346, Oct. 2003.
China, in 1974. She received the B.S. and M.S.
[14] M. Taboada, ‘‘Lexicon-based methods for sentiment analysis,’’ Comput.
degrees from the Changchun University of Tech-
Linguistics, vol. 37, no. 2, pp. 267–307, Jun. 2011.
[15] B. Pang, L. Lee, and S. Vaithyanathan, ‘‘Thumbs up?: Sentiment clas-
nology, in 1998 and 2002, respectively, and the
sification using machine learning techniques,’’ in Proc. Conf. Empirical Ph.D. degree in computer software and theory
Methods Natural Lang. Process. (ACL), Grenoble, France, Jul. 2002, from the Beijing Institute of Technology, in 2010.
pp. 79–86. Since 2002, she has been a Teacher with the
[16] A. B. Goldberg and X. Zhu, ‘‘Seeing stars when there aren’t many Information Engineering College, Minzu Uni-
stars: Graph-based semi-supervised learning for sentiment categoriza- versity of China. She is currently an Associate
tion,’’ in Proc. Workshop Graph Based Methods Natural Lang. Process., Professor. Her research interests include data
Sydney, VIC, Australia, Jun. 2006, pp. 45–52. mining and machine learning.
YUETING MENG was born in Shijiazhuang, ZIHENG YU was born in Taizhou, Zhejiang,
Hebei, China, in 1996. She received the B.S. China, in 1994. He received the B.S. degree in
degree in computer science and technology from software engineering from Beijing Union Univer-
the Hebei University of Science and Technology, sity, in 2017. He is currently pursuing the master’s
in 2018. She is currently pursuing the master’s degree in software engineering with the Minzu
degree in software engineering with the Minzu University of China. His research interests include
University of China. Her research interests include data mining, natural language processing, and arti-
artificial intelligence, natural language processing, ficial intelligence.
and data mining.
XIAOYU QIU received the M.S. degree in com- XU WU was born in Fenghuang, Hunan, China,
puter science from Shandong Normal University, in 1993. He received the B.S. degree in software
in 2008. He is currently a Librarian with the engineering from the Chongqing University of
Library of Shandong University of Traditional Posts and Telecommunications, in 2017. He is
Chinese Medicine. His current research interests currently pursuing the master’s degree in mod-
include different aspects of pattern recognition, ern education technology with the Minzu Univer-
artificial intelligence, and distributed systems. sity of China. His research interests include data
mining, natural language processing, and artificial
intelligence.