# Deep Learning-Based Text Sentiment Analysis in Chinese International Promotion

Authors: Ge Yao
Journal: Security and Communication Networks
 (2022)

---

## Abstract

The importance of teaching Chinese as a foreign language has grown in tandem with the rapid advancement of China’s politics and economy. The Chinese language’s international promotion strategy has taken shape, and it has become a major cause for our country and nation. Under such a new situation, the content and form of Chinese cultural communication have taken on new characteristics. Foreign friends will use a variety of ways to express their emotions and attitudes toward the Chinese on the Internet, most of which are mainly text comments. Sentiment analysis of text comments can provide valuable emotional information for our Chinese international communication and promotion activities. Text sentiment analysis using deep learning algorithms has advanced considerably in recent years. For that purpose, this study proposes a bidirectional long- and short-term memory network, as well as a text sentiment analysis model with a self-attentive mechanism, and applies it to comments on Chinese language promotion. Experiments show that our model achieves a good recognition situation and has application value.


---

## Body

## 1. Introduction

As China’s economy progresses and its international status enhances, more and more people want to understand Chinese society and Chinese culture [1]. Language is the carrier of culture, and language education and cultural transmission go hand in hand [2]. To make the excellent Chinese culture spread out better, we must pay attention to the teaching and promotion of the Chinese language. International promotion of the Chinese language has now become a national strategy, and its importance has risen significantly [3]. The content and methods of cultural dissemination have been deepened and enriched, and the teaching of Chinese as a foreign language has realized the transformation into the all-around international promotion of Chinese. With China’s steady and rapid economic growth, especially its accession to the World Trade Organization (WTO), the successful holding of the Beijing Olympic Games, and the perfect conclusion of the 2022 Winter Olympics, China’s international influence has been further strengthened, and the pattern of China’s all-round opening to the outside world has been formed. In the context of global integration, the promotion of the Chinese language in the world is of great practical significance in spreading and promoting Chinese culture and enhancing mutual understanding and friendship between China and people all over the world.International promotion of Chinese is first and foremost the promotion of Chinese language teaching, and language is the cornerstone and permanent carrier of culture [4]. Different languages contain certain cultural contents, from small words to large vocabularies, and even different sentence forms and rhetoric [5]. Language structure culture refers to the structural characteristics of words, phrases, sentences, and discourse, such as the pronunciation and tones of the Chinese language, which give the Chinese language a sense of rhythm and rhyme and a distinctive musical character. The ancient block characters are loaded with profound culture and contain a strong vitality and have played a key player in the cultural progression of neighboring peoples and regions in the world.However, the level of Chinese beginners varies, the expression of comments in Chinese is more random, and there will be a large amount of meaningless data [6]. When we are faced with a large amount of irregular data, we cannot directly use it to get the intuitive information we need and thus cannot draw meaningful conclusions for our promotion strategy [7]. In this situation, if we can purify the huge amount of data and classify and analyze the information according to the mathematical model, it can help us or other research institutions to directly analyze which evaluations are positive and which evaluations are negative for the Chinese language promotion. In other words, by evaluating the ratio of Chinese learners with negative and positive reviews, we can quickly assist participants to access information with a reference value, enhance their understanding of Chinese language promotion, and obtain information with more reference value. At the same time, it also contributes to our improvement of the shortcomings of Chinese language promotion.Research on natural language processing has been a hot topic [8], of which text sentiment analysis is a key theme. Text sentiment analysis is an interdisciplinary area of interest, which involves computer science, linguistics, and psychology [9]. According to the definition of sentiment, there are four main components of sentiment, which are viewpoint emitter, evaluation object, evaluation polarity, and evaluation time. The acquisition time of text can be set by simple rules among them, and therefore, the purpose of text sentiment analysis is to extract the three parts of opinion emitter, evaluation object, and evaluation polarity from the rule-free text. The system of sentiment categories fluctuates based on the work and usually incorporates positive and negative feelings [10]. Sentiment polarity is defined as the sentiment conveyed by the user, and it varies depending on the activity. Sentiment analysis in the text is further divided into display sentiment and implicit sentiment: display sentiment is the direct presence of sentiment words in the text, and the implicit sentiment is the absence of obvious sentiment words in the text. The analysis of implicit textual emotions is more difficult and relies on background knowledge and common sense. In late years, along with the quick advances in computer hardware, deep learning techniques that are based on neural networks are now extremely popular lines of research in computer science. Deep learning technology has also developed at a high speed and has been widely applied in the industry with very good results. Compared with the methods based on sentiment dictionary and traditional machine learning, the text sentiment analysis method based on deep learning has its unique advantages.The section-by-section study paragraph is as follows: Section2 overviews the related work. Section 3 discusses the methods of the proposed concepts. Section 4 discusses the experiments and results; Section 5 concludes the article.


## 2. Related Works

In this section, we explain the text sentiment analysis research and deep learning-based text sentiment analysis briefly.


### 2.1. Text Sentiment Analysis Research

Text sentiment analysis is among the more active topics in natural language processing (NLP) research, which was proposed by Pang et al. [11]. Because of its important role for both society and business, text sentiment analysis has changed from an initial research topic in the field of computer science to a research topic at the intersection of multiple disciplines.Liu et al. in 2012 detailed sentiment analysis, and according to the study approach, text sentiment analysis methods can be divided into supervised and unsupervised [12]. After years of development, the main methods of text sentiment analysis are divided into three directions: sentiment lexicon-based methods, traditional machine learning methods, and deep learning methods. Sentiment lexicon-based approaches focus on the statistical frequency of sentiment words in a text to identify the sentiment tendency of the text. Traditional machine learning-based approaches use processed and labeled data to build a classifier, which is then applied to ascertain the sentiment propensity of unlabeled data.Traditional machine learning-based methods applied to text sentiment analysis are the more popular research methods, which are capable of generating text sentiment analysis models by learning from training datasets and performing feature extraction. Some of the more commonly used traditional machine learning algorithms in text sentiment analysis are plain Bayesian, support vector machine, and maximum entropy methods. Pang et al. used a support vector machine, plain Bayesian, and maximum entropy methods for text sentiment analysis of movie review dataset, and the experiments proved that the text sentiment analysis by support vector machine achieved better results [13]. Al-Smadi et al. [14] used a support vector machine-based approach for text sentiment analysis of financial domain news with a particle swarm algorithm to optimize the parameters. Huang et al. [15] achieved better results for text sentiment analysis of financial information using the Stanford language-dependent support vector machine approach. Yan et al. [16] established a sentiment analysis system for Tibetan text analysis based on the maximized entropy method building on the grammatical analysis of the Tibetan language and achieved better results.


### 2.2. Deep Learning-Based Text Sentiment Analysis

Sentiment lexicon-related approaches and traditional machine learning-based approaches have achieved many excellent research results in text sentiment analysis studies, but require a lot of labor cost in the preliminary data processing. Deep learning is a technology belonging to machine learning, which is a general term for a series of algorithms based on feature self-learning and deep neural networks. In recent times, with the speedy growth of hardware, cloud computing, big data, and other technologies, the research and application of deep learning have also changed dramatically. Relative to conventional machine learning methods, deep learning reduces the humanization factor, has a deeper model depth, imitates the mechanism of the human brain processing data, and can extract the features of data deeply. At present, deep learning has made significant contributions in the areas of computer vision, machine translation, and biomedical analysis, and more and more deep learning methods are being applied to text sentiment analysis.Kim suggested a convolutional neural network-based text convolutional neural network (CNN) applied to the task of text classification, applying six datasets for experimental comparison, and proved that text CNN is more effective on some simple text classification tasks [17]. Yu et al. investigated the problem of sentence sentiment analysis across domains and devised a model involving two separate convolutional neural networks that collectively learn two closed feature representations from labeled and unlabeled data [18]. Guan et al. [19] used a weakly supervised convolutional neural network for sentiment classification, and the framework consists of two steps: the first step learns a sentence representation that is weakly supervised by the overall score, and the second step uses sentences with labels for fine-tuning. To perform text sentiment analysis on the Twitter corpus, Zhao et al. coupled potential contextual semantic linkages and co-occurrence statistical data between terms on Twitter with convolutional neural networks [20]. Wang et al. used a long short-term memory network for Twitter sentiment classification by simulating word interactions in the synthesis process [21]. Huang et al. proposed encoding grammatical knowledge in a tree-shaped long- and short-term memory network to enhance the representation of phrases and sentences [22]. Teng et al. proposed a context-sensitive lexicon-based sentiment analysis method using a bidirectional long- and short-term memory network to learn sentiment intensity [23].Because Chinese and English have distinct linguistic properties, using deep learning models developed for sentiment analysis of English text to Chinese text will not yield the best results. The self-attentive mechanism can learn the dependence link between words within a phrase and capture the sentence’s internal structure, but the bidirectional long- and short-term memory network can capture the text’s long-distance dependency relationship in both directions. Therefore, the model in this study will combine the two-way long- and short-term memory network with the self-attentive mechanism for Chinese text sentiment analysis.


## 2.1. Text Sentiment Analysis Research

Text sentiment analysis is among the more active topics in natural language processing (NLP) research, which was proposed by Pang et al. [11]. Because of its important role for both society and business, text sentiment analysis has changed from an initial research topic in the field of computer science to a research topic at the intersection of multiple disciplines.Liu et al. in 2012 detailed sentiment analysis, and according to the study approach, text sentiment analysis methods can be divided into supervised and unsupervised [12]. After years of development, the main methods of text sentiment analysis are divided into three directions: sentiment lexicon-based methods, traditional machine learning methods, and deep learning methods. Sentiment lexicon-based approaches focus on the statistical frequency of sentiment words in a text to identify the sentiment tendency of the text. Traditional machine learning-based approaches use processed and labeled data to build a classifier, which is then applied to ascertain the sentiment propensity of unlabeled data.Traditional machine learning-based methods applied to text sentiment analysis are the more popular research methods, which are capable of generating text sentiment analysis models by learning from training datasets and performing feature extraction. Some of the more commonly used traditional machine learning algorithms in text sentiment analysis are plain Bayesian, support vector machine, and maximum entropy methods. Pang et al. used a support vector machine, plain Bayesian, and maximum entropy methods for text sentiment analysis of movie review dataset, and the experiments proved that the text sentiment analysis by support vector machine achieved better results [13]. Al-Smadi et al. [14] used a support vector machine-based approach for text sentiment analysis of financial domain news with a particle swarm algorithm to optimize the parameters. Huang et al. [15] achieved better results for text sentiment analysis of financial information using the Stanford language-dependent support vector machine approach. Yan et al. [16] established a sentiment analysis system for Tibetan text analysis based on the maximized entropy method building on the grammatical analysis of the Tibetan language and achieved better results.


## 2.2. Deep Learning-Based Text Sentiment Analysis

Sentiment lexicon-related approaches and traditional machine learning-based approaches have achieved many excellent research results in text sentiment analysis studies, but require a lot of labor cost in the preliminary data processing. Deep learning is a technology belonging to machine learning, which is a general term for a series of algorithms based on feature self-learning and deep neural networks. In recent times, with the speedy growth of hardware, cloud computing, big data, and other technologies, the research and application of deep learning have also changed dramatically. Relative to conventional machine learning methods, deep learning reduces the humanization factor, has a deeper model depth, imitates the mechanism of the human brain processing data, and can extract the features of data deeply. At present, deep learning has made significant contributions in the areas of computer vision, machine translation, and biomedical analysis, and more and more deep learning methods are being applied to text sentiment analysis.Kim suggested a convolutional neural network-based text convolutional neural network (CNN) applied to the task of text classification, applying six datasets for experimental comparison, and proved that text CNN is more effective on some simple text classification tasks [17]. Yu et al. investigated the problem of sentence sentiment analysis across domains and devised a model involving two separate convolutional neural networks that collectively learn two closed feature representations from labeled and unlabeled data [18]. Guan et al. [19] used a weakly supervised convolutional neural network for sentiment classification, and the framework consists of two steps: the first step learns a sentence representation that is weakly supervised by the overall score, and the second step uses sentences with labels for fine-tuning. To perform text sentiment analysis on the Twitter corpus, Zhao et al. coupled potential contextual semantic linkages and co-occurrence statistical data between terms on Twitter with convolutional neural networks [20]. Wang et al. used a long short-term memory network for Twitter sentiment classification by simulating word interactions in the synthesis process [21]. Huang et al. proposed encoding grammatical knowledge in a tree-shaped long- and short-term memory network to enhance the representation of phrases and sentences [22]. Teng et al. proposed a context-sensitive lexicon-based sentiment analysis method using a bidirectional long- and short-term memory network to learn sentiment intensity [23].Because Chinese and English have distinct linguistic properties, using deep learning models developed for sentiment analysis of English text to Chinese text will not yield the best results. The self-attentive mechanism can learn the dependence link between words within a phrase and capture the sentence’s internal structure, but the bidirectional long- and short-term memory network can capture the text’s long-distance dependency relationship in both directions. Therefore, the model in this study will combine the two-way long- and short-term memory network with the self-attentive mechanism for Chinese text sentiment analysis.


## 3. Methods

### 3.1. Text Sentiment Analysis

The fundamental process of text sentiment analysis is illustrated in Figure1, which mainly includes the steps of text data collection, data preprocessing, feature annotation and selection, model training, model tuning, and sentiment analysis results.Figure 1
A workflow diagram for text sentiment analysis.


#### 3.1.1. Text Data Collection

When performing sentiment analysis on text, an essential step is to acquire text data. There are two main methods of acquiring datasets: one is research for general methods, which can be obtained from publicly available datasets from data mining competition websites such as UCI, Kaggle, and data mining competitions organized by Internet companies. The second is the research for specific fields, which can obtain specific datasets by means of Web crawlers.


#### 3.1.2. Data Preprocessing

In all data mining projects, the data preprocessing step is indispensable. The main purpose of text preprocessing is to remove irrelevant content from the task and extract key information for natural language processing. The preprocessing session for the Chinese language mainly includes normalizing the text, Chinese word separation, and deactivating words.


#### 3.1.3. Evaluation Metrics

After completing the construction of the sentiment analysis model, the effectiveness of the model must be evaluated, and the parameters of the model must continue to be adjusted according to the evaluation results of the model to finally achieve a better model. Evaluation metrics can not only describe the performance of the model but also identify the results of the model. The evaluation metrics in sentiment analysis research are similar to those in classification problems. In this study, four evaluation metrics, accuracy, precision, recall, andF1 score, will be used in the sentiment analysis research, as illustrated in Table 1.Table 1
Correlation between evaluation indicators.
True value10Predicted value1True positive (TP)False positive (FP)0False negative (FN)True negative (TN)The accuracy rate represents the ratio of the sample number of correct predictions to the total sample number and is expressed as follows:(1)Accuracy=TP+TNTP+FP+FN+TN.The accuracy rate indicates the number of correct predictions in the data with positive predictions and is defined as follows:(2)Precision=TPTP+FP.The recall represents the number of correct predictions in the data that are true-positive cases and is defined as follows:(3)recall=TPTP+FN.The F1 score is a balanced metric of precision and recall and is defined as follows:(4)F1=2×precision×recallprecision+recall.The greater the precision, the better the capabilities of the model to differentiate negative samples. The recall is a well-defined measure of the model’s capability to discriminate positive samples. The larger the recall rate, the stronger the model’s capability to distinguish positive samples. Accuracy and recall are contradictory measures, and they cannot be obtained at the same time, while the F1 score can be used for both evaluation metrics.


### 3.2. A Bidirectional Long Short-Term Memory Network Combining Self-Attentive Mechanisms

The attentional mechanism was first raised in the realm of computer vision. It mimics an internal process of biological observation behavior, i.e., a mechanism that aligns external senses with internal experience to increase the degree of observation in a particular region. As researchers delved deeper into the attentional mechanism, a variety of attentional mechanisms were proposed.In 2017, the Google machine translation team proposed a self-attentive mechanism that does not rely on the additional reference information, which was applied to the WMT2014 corpus machine translation task with very good results and faster training speed than other mainstream machine translation models. Tan et al. achieved better results on several datasets after using the self-attentive mechanism on the task of semantic role labeling. Self-attentive mechanisms can be viewed as a privileged instance of attentional mechanisms, which reduces the reliance of the attentional mechanism on external reference information and is able to ignore the distance between words, thus directly computing the interdependencies between words and capturing the internal structure in sentences. Long short-term memory networks are well suited for processing textual data because they can capture long-distance dependencies on sequences very well. However, long short-term memory networks suffer from the drawback of not being able to encode back-to-front information. Schuster et al. proposed the bidirectional long short-term memory (BiLSTM) network, which consists of a forward and a backward long short-term memory network.


#### 3.2.1. Word Vector Technology

Natural languages such as Chinese and English are essentially languages in which humans communicate with each other, and current computers can only process binary data and do not have the means to directly process human languages. To give natural language to algorithms in machine learning to process it, it must be Americanized. One way of numericalizing words in natural language is the word vector technique. The use of word vectors in natural language processing tasks has many advantages. Word vectors can represent the connections and differences between words, allowing deep learning models to capture the internal structure in sentences. Word vectors are obtained from pretraining, and a single word vector can be used in multiple tasks. A word vector is a fixed-length continuous dense vector that consumes few resources and is fast to compute. The word vector models frequently used in deep learning are word2vec, glove, and BERT.


#### 3.2.2. Self-Attentive Mechanism

Attentional mechanisms mimic the intrinsic processes of biological observational actions, i.e., a mechanism that brings the external senses into conformity with internal processes of experience to enhance the degree of observation of a particular area. Simultaneous translation and alignment in machine translation using neural networks result in a significant improvement in text translation accuracy compared with other models. In the current research, the attentional mechanism is usually combined with the encoder-decoder framework, as shown in Figure2, which is a common encoder-decoder framework in the text domain.Figure 2
Text processing domain encoder-decoder framework.The encoder-decoder framework in the text processing domain can be viewed as a process in which the input sentence source is generated as a target after the encoder-decoder operation. As can be seen from the encoder-decoder framework in Figure2, each y generation requires the same semantic encoding C, without highlighting the keywords in the sentence. Therefore, the encoder-decoder framework with added attentional mechanism is shown in Figure 3.Figure 3
Encoder-decoder framework that introduces the attentional model.After adding the attentional mechanism to the encoder-decoder framework, the semantic encodingC fixed in the original framework becomes ci, and ci is dynamically adjusted according to the current output words in conjunction with the attentional model; i.e., each word in the target should learn the attentional assignment probability of its corresponding word in the source utterance.The attentional mechanism is separated from the encoder-decoder framework and is essentially a mapping function consisting of multiple query and key-value combinations, as shown in Figure4.Figure 4
Essence of the attentional mechanism.The formula for the essential idea of the attentional mechanism is expressed as follows:(5)AttentionQuery,Source=∑i=1LxSimilarityQuery,Keyi∗Valuei,where Lx=Source represents the length of source.The calculation of attention can be broken down into three stations.(1)
To calculate the similarity between query and key, the common methods to find the similarity are the vector dot product of the two (as in Equation (6)) and the vector cosine similarity of the two (as in Equation (7)).(6)SimQ,Ki=Q⋅Ki,(7)SimQ,Ki=Q⋅KiQKi.(2)
Thesoftmax function is used to normalize the weights and highlight the weights of important elements, as shown as follows:(8)ai=SoftmaxSimi=eSimi∑j=1LxeSimj.(3)
The weights and the corresponding values are weighed and summed to obtain the attentional value, as shown as follows:(9)AttentionQ,S=∑i=1Lxai⋅Vi, where K denotes the keyword, Q denotes the query, and V denotes the weight value.According to the above computational process, the computational process of the attentional mechanism is abstracted as shown in Figure5. Among them, F denotes the function, s denotes the similarity, and a denotes the weight coefficient.Figure 5
Calculation process of attentional mechanism.Self-attentive mechanisms can be viewed as a particular case of attentional mechanisms, also known as the internal attentional mechanism. The self-attentive mechanism is able to ignore the distance between words and thus directly calculate the interdependencies between words and capture the internal structure in a sentence. In traditional attentional mechanisms, some external information is used to align with the internal information, while in the self-attentive mechanism the model only needs to be trained to adjust the parameters based on its own information. The self-attentive mechanism, i.e.,K=V=Q, calculates the attentional value of each word inside the sentence with respect to other words in the sentence for an input sentence, as shown as follows:(10)AttentionX=SoftmaxX⋅XTdkX,where X∈Rn is the n-dimensional input vector and dk is the dimension of the input vector, which acts as a regulator to avoid the situation where the inner product of X⋅XT is too large resulting in a softmax value other than 0, which is 1. The self-attentive mechanism directly links any two words in a sentence during computation, so the self-attentive mechanism can reduce the distance between two features with dependencies.


#### 3.2.3. Bidirectional Long- and Short-Term Memory Network

Long short-term memory (LSTM) networks are well suited for processing textual data because they can capture long-distance dependencies on sequences very well. In the long short-term memory network, just the above information is actually used, and no below information is used. In practical application scenarios, the entire input context information needs to be used, so the long short-term memory network has the drawback of not being able to encode information from back to front. The bidirectional long short-term memory network consists of a forward LSTM network and a backward LSTM network, as shown in Figure6. The vector output from the two LSTM layers can be processed by summing, averaging, or concatenating.Figure 6
BiLSTM model structure.The output of the bidirectional long short-term memory network at timet is denoted as ht, as shown as follows:(11)ht=ht⟶⊕ht←,where ht⟶ denotes the output to the long- and short-term memory network before the moment t and ht← indicates the output to the long- and short-term memory network after t moments.


#### 3.2.4. SA-BiLSTM Network Structure

In the text sentiment analysis task, we utilize a modified SA-BiLSTM network architecture to decrease the dependence on extrinsic information while focusing on the key information in short texts. It can retain the sparse features in the short text and better extract the key features that play an important role in text sentiment analysis. As shown in Figure7, the SA-BiLSTM network architecture is divided into four layers: the first layer is the word vector input layer, which converts Chinese text into word vectors for input into the network structure. The second layer is the feature learning layer, which uses a bidirectional long- and short-term memory network to obtain text features from the input word vectors. The third layer is the weight adjustment layer, which uses a self-attentive mechanism to adjust the weight of each feature. The fourth layer is the sentiment analysis layer, which outputs the probability that the text belongs to each sentiment tendency.Figure 7
SA-BiLSTM model structure.(1) Word Vector Input Layer. After the Chinese text is processed by word separation, a distributed word vector model is used to represent the words. For an input sentence S containing T words: S=X1⊕X2⊕⋯⊕XT. In the deep learning network, each word Xi is represented by n-dimensional word vector representation: Xi=wx1,wx2,…,wxn. Eventually, each Chinese text sentence S is converted into a word vector feature matrix W passed to the next layer of the deep learning network, where W∈RT+n.(2) Feature Learning Layer. The long- and short-term memory network brings in a gate mechanism in the ordinary recurrent neural network to control the transfer of information. The forgetting gate decides to discard information that is not needed for the unit state.(12)ft=SigmoidWf⋅ht−1,xt+bf.The input gate determines the information added to the cell state.(13)it=SigmoidWi⋅ht−1,xt+biCt˜=tanhWC⋅ht−1,xt+bCCt=ft×Ct−1+it×Ct˜.The output gate determines the output information.(14)ot=SigmoidWo⋅ht−1,xt+boht=ot×tanhCt.(3) Weight Adjustment Layer. The self-attentive mechanism is able to ignore the distance between words, thus directly calculating the interdependence between word relationships and capture the internal structure in the sentences.(15)a=SoftmaxX⋅XTdkXr=aH,where dk is the dimension of the input vector, which plays a moderating role, a is the attentional value, and H is a feature of the output of the bidirectional long- and short-term network.(4) Sentiment Analysis Layer. Softmax function is used to predict the predictions for each of these categories.(16)py=Softmaxw′⋅r+b.


## 3.1. Text Sentiment Analysis

The fundamental process of text sentiment analysis is illustrated in Figure1, which mainly includes the steps of text data collection, data preprocessing, feature annotation and selection, model training, model tuning, and sentiment analysis results.Figure 1
A workflow diagram for text sentiment analysis.


### 3.1.1. Text Data Collection

When performing sentiment analysis on text, an essential step is to acquire text data. There are two main methods of acquiring datasets: one is research for general methods, which can be obtained from publicly available datasets from data mining competition websites such as UCI, Kaggle, and data mining competitions organized by Internet companies. The second is the research for specific fields, which can obtain specific datasets by means of Web crawlers.


### 3.1.2. Data Preprocessing

In all data mining projects, the data preprocessing step is indispensable. The main purpose of text preprocessing is to remove irrelevant content from the task and extract key information for natural language processing. The preprocessing session for the Chinese language mainly includes normalizing the text, Chinese word separation, and deactivating words.


### 3.1.3. Evaluation Metrics

After completing the construction of the sentiment analysis model, the effectiveness of the model must be evaluated, and the parameters of the model must continue to be adjusted according to the evaluation results of the model to finally achieve a better model. Evaluation metrics can not only describe the performance of the model but also identify the results of the model. The evaluation metrics in sentiment analysis research are similar to those in classification problems. In this study, four evaluation metrics, accuracy, precision, recall, andF1 score, will be used in the sentiment analysis research, as illustrated in Table 1.Table 1
Correlation between evaluation indicators.
True value10Predicted value1True positive (TP)False positive (FP)0False negative (FN)True negative (TN)The accuracy rate represents the ratio of the sample number of correct predictions to the total sample number and is expressed as follows:(1)Accuracy=TP+TNTP+FP+FN+TN.The accuracy rate indicates the number of correct predictions in the data with positive predictions and is defined as follows:(2)Precision=TPTP+FP.The recall represents the number of correct predictions in the data that are true-positive cases and is defined as follows:(3)recall=TPTP+FN.The F1 score is a balanced metric of precision and recall and is defined as follows:(4)F1=2×precision×recallprecision+recall.The greater the precision, the better the capabilities of the model to differentiate negative samples. The recall is a well-defined measure of the model’s capability to discriminate positive samples. The larger the recall rate, the stronger the model’s capability to distinguish positive samples. Accuracy and recall are contradictory measures, and they cannot be obtained at the same time, while the F1 score can be used for both evaluation metrics.


## 3.1.1. Text Data Collection

When performing sentiment analysis on text, an essential step is to acquire text data. There are two main methods of acquiring datasets: one is research for general methods, which can be obtained from publicly available datasets from data mining competition websites such as UCI, Kaggle, and data mining competitions organized by Internet companies. The second is the research for specific fields, which can obtain specific datasets by means of Web crawlers.


## 3.1.2. Data Preprocessing

In all data mining projects, the data preprocessing step is indispensable. The main purpose of text preprocessing is to remove irrelevant content from the task and extract key information for natural language processing. The preprocessing session for the Chinese language mainly includes normalizing the text, Chinese word separation, and deactivating words.


## 3.1.3. Evaluation Metrics

After completing the construction of the sentiment analysis model, the effectiveness of the model must be evaluated, and the parameters of the model must continue to be adjusted according to the evaluation results of the model to finally achieve a better model. Evaluation metrics can not only describe the performance of the model but also identify the results of the model. The evaluation metrics in sentiment analysis research are similar to those in classification problems. In this study, four evaluation metrics, accuracy, precision, recall, andF1 score, will be used in the sentiment analysis research, as illustrated in Table 1.Table 1
Correlation between evaluation indicators.
True value10Predicted value1True positive (TP)False positive (FP)0False negative (FN)True negative (TN)The accuracy rate represents the ratio of the sample number of correct predictions to the total sample number and is expressed as follows:(1)Accuracy=TP+TNTP+FP+FN+TN.The accuracy rate indicates the number of correct predictions in the data with positive predictions and is defined as follows:(2)Precision=TPTP+FP.The recall represents the number of correct predictions in the data that are true-positive cases and is defined as follows:(3)recall=TPTP+FN.The F1 score is a balanced metric of precision and recall and is defined as follows:(4)F1=2×precision×recallprecision+recall.The greater the precision, the better the capabilities of the model to differentiate negative samples. The recall is a well-defined measure of the model’s capability to discriminate positive samples. The larger the recall rate, the stronger the model’s capability to distinguish positive samples. Accuracy and recall are contradictory measures, and they cannot be obtained at the same time, while the F1 score can be used for both evaluation metrics.


## 3.2. A Bidirectional Long Short-Term Memory Network Combining Self-Attentive Mechanisms

The attentional mechanism was first raised in the realm of computer vision. It mimics an internal process of biological observation behavior, i.e., a mechanism that aligns external senses with internal experience to increase the degree of observation in a particular region. As researchers delved deeper into the attentional mechanism, a variety of attentional mechanisms were proposed.In 2017, the Google machine translation team proposed a self-attentive mechanism that does not rely on the additional reference information, which was applied to the WMT2014 corpus machine translation task with very good results and faster training speed than other mainstream machine translation models. Tan et al. achieved better results on several datasets after using the self-attentive mechanism on the task of semantic role labeling. Self-attentive mechanisms can be viewed as a privileged instance of attentional mechanisms, which reduces the reliance of the attentional mechanism on external reference information and is able to ignore the distance between words, thus directly computing the interdependencies between words and capturing the internal structure in sentences. Long short-term memory networks are well suited for processing textual data because they can capture long-distance dependencies on sequences very well. However, long short-term memory networks suffer from the drawback of not being able to encode back-to-front information. Schuster et al. proposed the bidirectional long short-term memory (BiLSTM) network, which consists of a forward and a backward long short-term memory network.


### 3.2.1. Word Vector Technology

Natural languages such as Chinese and English are essentially languages in which humans communicate with each other, and current computers can only process binary data and do not have the means to directly process human languages. To give natural language to algorithms in machine learning to process it, it must be Americanized. One way of numericalizing words in natural language is the word vector technique. The use of word vectors in natural language processing tasks has many advantages. Word vectors can represent the connections and differences between words, allowing deep learning models to capture the internal structure in sentences. Word vectors are obtained from pretraining, and a single word vector can be used in multiple tasks. A word vector is a fixed-length continuous dense vector that consumes few resources and is fast to compute. The word vector models frequently used in deep learning are word2vec, glove, and BERT.


### 3.2.2. Self-Attentive Mechanism

Attentional mechanisms mimic the intrinsic processes of biological observational actions, i.e., a mechanism that brings the external senses into conformity with internal processes of experience to enhance the degree of observation of a particular area. Simultaneous translation and alignment in machine translation using neural networks result in a significant improvement in text translation accuracy compared with other models. In the current research, the attentional mechanism is usually combined with the encoder-decoder framework, as shown in Figure2, which is a common encoder-decoder framework in the text domain.Figure 2
Text processing domain encoder-decoder framework.The encoder-decoder framework in the text processing domain can be viewed as a process in which the input sentence source is generated as a target after the encoder-decoder operation. As can be seen from the encoder-decoder framework in Figure2, each y generation requires the same semantic encoding C, without highlighting the keywords in the sentence. Therefore, the encoder-decoder framework with added attentional mechanism is shown in Figure 3.Figure 3
Encoder-decoder framework that introduces the attentional model.After adding the attentional mechanism to the encoder-decoder framework, the semantic encodingC fixed in the original framework becomes ci, and ci is dynamically adjusted according to the current output words in conjunction with the attentional model; i.e., each word in the target should learn the attentional assignment probability of its corresponding word in the source utterance.The attentional mechanism is separated from the encoder-decoder framework and is essentially a mapping function consisting of multiple query and key-value combinations, as shown in Figure4.Figure 4
Essence of the attentional mechanism.The formula for the essential idea of the attentional mechanism is expressed as follows:(5)AttentionQuery,Source=∑i=1LxSimilarityQuery,Keyi∗Valuei,where Lx=Source represents the length of source.The calculation of attention can be broken down into three stations.(1)
To calculate the similarity between query and key, the common methods to find the similarity are the vector dot product of the two (as in Equation (6)) and the vector cosine similarity of the two (as in Equation (7)).(6)SimQ,Ki=Q⋅Ki,(7)SimQ,Ki=Q⋅KiQKi.(2)
Thesoftmax function is used to normalize the weights and highlight the weights of important elements, as shown as follows:(8)ai=SoftmaxSimi=eSimi∑j=1LxeSimj.(3)
The weights and the corresponding values are weighed and summed to obtain the attentional value, as shown as follows:(9)AttentionQ,S=∑i=1Lxai⋅Vi, where K denotes the keyword, Q denotes the query, and V denotes the weight value.According to the above computational process, the computational process of the attentional mechanism is abstracted as shown in Figure5. Among them, F denotes the function, s denotes the similarity, and a denotes the weight coefficient.Figure 5
Calculation process of attentional mechanism.Self-attentive mechanisms can be viewed as a particular case of attentional mechanisms, also known as the internal attentional mechanism. The self-attentive mechanism is able to ignore the distance between words and thus directly calculate the interdependencies between words and capture the internal structure in a sentence. In traditional attentional mechanisms, some external information is used to align with the internal information, while in the self-attentive mechanism the model only needs to be trained to adjust the parameters based on its own information. The self-attentive mechanism, i.e.,K=V=Q, calculates the attentional value of each word inside the sentence with respect to other words in the sentence for an input sentence, as shown as follows:(10)AttentionX=SoftmaxX⋅XTdkX,where X∈Rn is the n-dimensional input vector and dk is the dimension of the input vector, which acts as a regulator to avoid the situation where the inner product of X⋅XT is too large resulting in a softmax value other than 0, which is 1. The self-attentive mechanism directly links any two words in a sentence during computation, so the self-attentive mechanism can reduce the distance between two features with dependencies.


### 3.2.3. Bidirectional Long- and Short-Term Memory Network

Long short-term memory (LSTM) networks are well suited for processing textual data because they can capture long-distance dependencies on sequences very well. In the long short-term memory network, just the above information is actually used, and no below information is used. In practical application scenarios, the entire input context information needs to be used, so the long short-term memory network has the drawback of not being able to encode information from back to front. The bidirectional long short-term memory network consists of a forward LSTM network and a backward LSTM network, as shown in Figure6. The vector output from the two LSTM layers can be processed by summing, averaging, or concatenating.Figure 6
BiLSTM model structure.The output of the bidirectional long short-term memory network at timet is denoted as ht, as shown as follows:(11)ht=ht⟶⊕ht←,where ht⟶ denotes the output to the long- and short-term memory network before the moment t and ht← indicates the output to the long- and short-term memory network after t moments.


### 3.2.4. SA-BiLSTM Network Structure

In the text sentiment analysis task, we utilize a modified SA-BiLSTM network architecture to decrease the dependence on extrinsic information while focusing on the key information in short texts. It can retain the sparse features in the short text and better extract the key features that play an important role in text sentiment analysis. As shown in Figure7, the SA-BiLSTM network architecture is divided into four layers: the first layer is the word vector input layer, which converts Chinese text into word vectors for input into the network structure. The second layer is the feature learning layer, which uses a bidirectional long- and short-term memory network to obtain text features from the input word vectors. The third layer is the weight adjustment layer, which uses a self-attentive mechanism to adjust the weight of each feature. The fourth layer is the sentiment analysis layer, which outputs the probability that the text belongs to each sentiment tendency.Figure 7
SA-BiLSTM model structure.(1) Word Vector Input Layer. After the Chinese text is processed by word separation, a distributed word vector model is used to represent the words. For an input sentence S containing T words: S=X1⊕X2⊕⋯⊕XT. In the deep learning network, each word Xi is represented by n-dimensional word vector representation: Xi=wx1,wx2,…,wxn. Eventually, each Chinese text sentence S is converted into a word vector feature matrix W passed to the next layer of the deep learning network, where W∈RT+n.(2) Feature Learning Layer. The long- and short-term memory network brings in a gate mechanism in the ordinary recurrent neural network to control the transfer of information. The forgetting gate decides to discard information that is not needed for the unit state.(12)ft=SigmoidWf⋅ht−1,xt+bf.The input gate determines the information added to the cell state.(13)it=SigmoidWi⋅ht−1,xt+biCt˜=tanhWC⋅ht−1,xt+bCCt=ft×Ct−1+it×Ct˜.The output gate determines the output information.(14)ot=SigmoidWo⋅ht−1,xt+boht=ot×tanhCt.(3) Weight Adjustment Layer. The self-attentive mechanism is able to ignore the distance between words, thus directly calculating the interdependence between word relationships and capture the internal structure in the sentences.(15)a=SoftmaxX⋅XTdkXr=aH,where dk is the dimension of the input vector, which plays a moderating role, a is the attentional value, and H is a feature of the output of the bidirectional long- and short-term network.(4) Sentiment Analysis Layer. Softmax function is used to predict the predictions for each of these categories.(16)py=Softmaxw′⋅r+b.


## 3.2.1. Word Vector Technology

Natural languages such as Chinese and English are essentially languages in which humans communicate with each other, and current computers can only process binary data and do not have the means to directly process human languages. To give natural language to algorithms in machine learning to process it, it must be Americanized. One way of numericalizing words in natural language is the word vector technique. The use of word vectors in natural language processing tasks has many advantages. Word vectors can represent the connections and differences between words, allowing deep learning models to capture the internal structure in sentences. Word vectors are obtained from pretraining, and a single word vector can be used in multiple tasks. A word vector is a fixed-length continuous dense vector that consumes few resources and is fast to compute. The word vector models frequently used in deep learning are word2vec, glove, and BERT.


## 3.2.2. Self-Attentive Mechanism

Attentional mechanisms mimic the intrinsic processes of biological observational actions, i.e., a mechanism that brings the external senses into conformity with internal processes of experience to enhance the degree of observation of a particular area. Simultaneous translation and alignment in machine translation using neural networks result in a significant improvement in text translation accuracy compared with other models. In the current research, the attentional mechanism is usually combined with the encoder-decoder framework, as shown in Figure2, which is a common encoder-decoder framework in the text domain.Figure 2
Text processing domain encoder-decoder framework.The encoder-decoder framework in the text processing domain can be viewed as a process in which the input sentence source is generated as a target after the encoder-decoder operation. As can be seen from the encoder-decoder framework in Figure2, each y generation requires the same semantic encoding C, without highlighting the keywords in the sentence. Therefore, the encoder-decoder framework with added attentional mechanism is shown in Figure 3.Figure 3
Encoder-decoder framework that introduces the attentional model.After adding the attentional mechanism to the encoder-decoder framework, the semantic encodingC fixed in the original framework becomes ci, and ci is dynamically adjusted according to the current output words in conjunction with the attentional model; i.e., each word in the target should learn the attentional assignment probability of its corresponding word in the source utterance.The attentional mechanism is separated from the encoder-decoder framework and is essentially a mapping function consisting of multiple query and key-value combinations, as shown in Figure4.Figure 4
Essence of the attentional mechanism.The formula for the essential idea of the attentional mechanism is expressed as follows:(5)AttentionQuery,Source=∑i=1LxSimilarityQuery,Keyi∗Valuei,where Lx=Source represents the length of source.The calculation of attention can be broken down into three stations.(1)
To calculate the similarity between query and key, the common methods to find the similarity are the vector dot product of the two (as in Equation (6)) and the vector cosine similarity of the two (as in Equation (7)).(6)SimQ,Ki=Q⋅Ki,(7)SimQ,Ki=Q⋅KiQKi.(2)
Thesoftmax function is used to normalize the weights and highlight the weights of important elements, as shown as follows:(8)ai=SoftmaxSimi=eSimi∑j=1LxeSimj.(3)
The weights and the corresponding values are weighed and summed to obtain the attentional value, as shown as follows:(9)AttentionQ,S=∑i=1Lxai⋅Vi, where K denotes the keyword, Q denotes the query, and V denotes the weight value.According to the above computational process, the computational process of the attentional mechanism is abstracted as shown in Figure5. Among them, F denotes the function, s denotes the similarity, and a denotes the weight coefficient.Figure 5
Calculation process of attentional mechanism.Self-attentive mechanisms can be viewed as a particular case of attentional mechanisms, also known as the internal attentional mechanism. The self-attentive mechanism is able to ignore the distance between words and thus directly calculate the interdependencies between words and capture the internal structure in a sentence. In traditional attentional mechanisms, some external information is used to align with the internal information, while in the self-attentive mechanism the model only needs to be trained to adjust the parameters based on its own information. The self-attentive mechanism, i.e.,K=V=Q, calculates the attentional value of each word inside the sentence with respect to other words in the sentence for an input sentence, as shown as follows:(10)AttentionX=SoftmaxX⋅XTdkX,where X∈Rn is the n-dimensional input vector and dk is the dimension of the input vector, which acts as a regulator to avoid the situation where the inner product of X⋅XT is too large resulting in a softmax value other than 0, which is 1. The self-attentive mechanism directly links any two words in a sentence during computation, so the self-attentive mechanism can reduce the distance between two features with dependencies.


## 3.2.3. Bidirectional Long- and Short-Term Memory Network

Long short-term memory (LSTM) networks are well suited for processing textual data because they can capture long-distance dependencies on sequences very well. In the long short-term memory network, just the above information is actually used, and no below information is used. In practical application scenarios, the entire input context information needs to be used, so the long short-term memory network has the drawback of not being able to encode information from back to front. The bidirectional long short-term memory network consists of a forward LSTM network and a backward LSTM network, as shown in Figure6. The vector output from the two LSTM layers can be processed by summing, averaging, or concatenating.Figure 6
BiLSTM model structure.The output of the bidirectional long short-term memory network at timet is denoted as ht, as shown as follows:(11)ht=ht⟶⊕ht←,where ht⟶ denotes the output to the long- and short-term memory network before the moment t and ht← indicates the output to the long- and short-term memory network after t moments.


## 3.2.4. SA-BiLSTM Network Structure

In the text sentiment analysis task, we utilize a modified SA-BiLSTM network architecture to decrease the dependence on extrinsic information while focusing on the key information in short texts. It can retain the sparse features in the short text and better extract the key features that play an important role in text sentiment analysis. As shown in Figure7, the SA-BiLSTM network architecture is divided into four layers: the first layer is the word vector input layer, which converts Chinese text into word vectors for input into the network structure. The second layer is the feature learning layer, which uses a bidirectional long- and short-term memory network to obtain text features from the input word vectors. The third layer is the weight adjustment layer, which uses a self-attentive mechanism to adjust the weight of each feature. The fourth layer is the sentiment analysis layer, which outputs the probability that the text belongs to each sentiment tendency.Figure 7
SA-BiLSTM model structure.(1) Word Vector Input Layer. After the Chinese text is processed by word separation, a distributed word vector model is used to represent the words. For an input sentence S containing T words: S=X1⊕X2⊕⋯⊕XT. In the deep learning network, each word Xi is represented by n-dimensional word vector representation: Xi=wx1,wx2,…,wxn. Eventually, each Chinese text sentence S is converted into a word vector feature matrix W passed to the next layer of the deep learning network, where W∈RT+n.(2) Feature Learning Layer. The long- and short-term memory network brings in a gate mechanism in the ordinary recurrent neural network to control the transfer of information. The forgetting gate decides to discard information that is not needed for the unit state.(12)ft=SigmoidWf⋅ht−1,xt+bf.The input gate determines the information added to the cell state.(13)it=SigmoidWi⋅ht−1,xt+biCt˜=tanhWC⋅ht−1,xt+bCCt=ft×Ct−1+it×Ct˜.The output gate determines the output information.(14)ot=SigmoidWo⋅ht−1,xt+boht=ot×tanhCt.(3) Weight Adjustment Layer. The self-attentive mechanism is able to ignore the distance between words, thus directly calculating the interdependence between word relationships and capture the internal structure in the sentences.(15)a=SoftmaxX⋅XTdkXr=aH,where dk is the dimension of the input vector, which plays a moderating role, a is the attentional value, and H is a feature of the output of the bidirectional long- and short-term network.(4) Sentiment Analysis Layer. Softmax function is used to predict the predictions for each of these categories.(16)py=Softmaxw′⋅r+b.


## 4. Experiments and Results

In this chapter, we define the experimental dataset, experimental data preprocessing, and experimental results in detail.


### 4.1. Experimental Dataset

For validating the capabilities of the suggested method, we collected a dataset of 7000 targeted Chinese promotion course reviews from Chinese catechism courses, which contain 5000 positive affective tendency datasets and 2000 negative affective tendency datasets. The distribution of sentence lengths after word separation with the word separation tool for the two experimental datasets is shown in Figure8. From Figure 8, we can find that the lengths of the two datasets after word separation are mainly within 200.Figure 8
Sentence length distribution.


### 4.2. Experimental Data Preprocessing

The Chinese catechism comment datasets used in the experiments in this study are all from Internet text data. The text data are a kind of unstructured data, and the dataset needs to be preprocessed before use.


#### 4.2.1. Normative Text

The Chinese catechism comment dataset collected in this study comes from different periods and different platforms, and the encoding format of the text data saved is unified as UTF-8 for the convenience of later use. Nowadays, each platform supports various symbols and expression comments, and in the experiment of this study, we mainly focus on Chinese text for sentiment analysis, so we need to remove the content and symbols in the text data that are invalid for this experiment.


#### 4.2.2. Chinese Word Splitting

After years of research on Chinese word separation technology, word separation algorithms can be summarized into the following three types: lexicon-based word separation algorithms, statistical-based word separation algorithms, and semantic understanding-based word separation algorithms. At present, the main popular Chinese word separation systems are Jieba word separation system, THULAC word separation tool, and PkuSeg word separation tool. In this study, PkuSeg is used to classify text. This study adopts the tourism domain model of PkuSeg to classify the text data.


#### 4.2.3. Deactivation Words

In text sentiment analysis, tone words and exclamations indicate the degree of sentiment and contribute to text sentiment analysis. According to the needs of text sentiment analysis in this study, the deactivation word list of HIT and the deactivation word list of Baidu are reintegrated.


### 4.3. Experimental Results

It must be numericalized to supply plain language to machine learning algorithms for processing. In today’s natural language processing jobs, the word vector technique is a common method. The Skip-gram model of the word2vec tool is used to train the word vectors in this part, and the Chinese Wikipedia corpus is used as the corpus for word vector training in this article. Since the Chinese Wikipedia corpus contains a large number of traditional Chinese characters, it is necessary to convert traditional Chinese characters to simplified Chinese characters before use.word2vec word vector training process parameters are set as displayed in Table 2.Table 2
Word2vec word embedding training process parameter setting.
ParameterValueParameter descriptionSg1Skip-gram model selected for trainingVector_size300Word vector dimensionWindow5Window sizeMin count10Words with less than 10 times word frequency are discardedThe main parameters used in the experiments in this article are displayed in Table3.Table 3
Hyperparameter configuration.
Network parametersTake valuef1η0.001batch_size32hidden_units256dropout0.1, 0.2, 0.3, 0.4, 0.5epoch1, 5, 10, 15, 20


#### 4.3.1. OptimizingEpoch Parameters

In deep learning-based model training, anepoch represents a complete deep learning training. In the actual training of the model, the quantity of iterations of model training has significant effects on the behavior of the model. A small quantity of model iterations will not allow the model to be fully trained and achieve better performance; too many model iterations will make the trained model overfitting and unable to be used for other datasets, which degrades the capability of the model to generalize. According to the epoch parameters in Table 3, several experiments were conducted, and the results of the experiment are shown in Table 4.Table 4
Epoch experiment results.
EpochAccuracyLoss rate10.80630.425950.82130.3989100.85380.3174150.88870.2874200.88640.2885From the results of the experiments with differentepochs in Table 4, the accuracy of the model increases first and then decreases, and the loss of the model decreases first and then increases when the epoch is gradually increased. The most accurate value of 0.887 was achieved for the model and the loss of the model reaches the minimum value of 0.2874 at the 15th epoch of training, and the accuracy and loss of the model change less after the 15th epoch, indicating that the model has converged.


#### 4.3.2. OptimizingDropout Parameters

Thedropout algorithm allows the model to be trained in such a way that the activation value of a neuron is suspended with a specific probability and does not rely too much on some unimportant local features, allowing the model to be more generalized. Several experiments were conducted according to the dropout parameters in Table 3, and the performance of the test is given in Table 5.Table 5
Dropout experiment results.
DropoutAccuracyLoss rate0.10.86880.31210.20.87520.30370.30.88640.28850.40.88970.28120.50.89120.2805According to the results of different dropout experiments in Table5, the accuracy of the model is higher when the dropout value is 0.5. The accuracy of the model is higher when the dropout value is 0.5.A contrast analysis experiment with other text sentiment analysis methods was designed on the obtained dataset to evaluate the validity of the text sentiment analysis method suggested in this work, and the experimental results are shown in Table6.Table 6
Experimental results.
ModelsPrecisionRecallFl scoreText CNN0.87380.85490.8643LSTM0.88200.83020.8553BiLSTM0.85750.89630.8765SA-BiLSTM0.87730.89910.8854By comparing the experimental results of LSTM and BiLSTM, the F1 score of BiLSTM outperforms the F1 score of LSTM in both datasets due to the addition of backward long- and short-term memory network in BiLSTM, which can capture both forward and backward semantic dependencies.By making a cross-comparison of the results of BiLSTM and SA-BiLSTM experiments, the combination of self-attentive mechanism and bidirectional long- and short-term memory network constitutes a new model that can fast detect significant features of sparse data, and the F1 score of SA-BiLSTM is higher than the F1 score of BiLSTM.The comparative analysis of the above experiments further confirms that the SA-BiLSTM model presented in this article could obtain superior outcomes in text sentiment analysis.


## 4.1. Experimental Dataset

For validating the capabilities of the suggested method, we collected a dataset of 7000 targeted Chinese promotion course reviews from Chinese catechism courses, which contain 5000 positive affective tendency datasets and 2000 negative affective tendency datasets. The distribution of sentence lengths after word separation with the word separation tool for the two experimental datasets is shown in Figure8. From Figure 8, we can find that the lengths of the two datasets after word separation are mainly within 200.Figure 8
Sentence length distribution.


## 4.2. Experimental Data Preprocessing

The Chinese catechism comment datasets used in the experiments in this study are all from Internet text data. The text data are a kind of unstructured data, and the dataset needs to be preprocessed before use.


### 4.2.1. Normative Text

The Chinese catechism comment dataset collected in this study comes from different periods and different platforms, and the encoding format of the text data saved is unified as UTF-8 for the convenience of later use. Nowadays, each platform supports various symbols and expression comments, and in the experiment of this study, we mainly focus on Chinese text for sentiment analysis, so we need to remove the content and symbols in the text data that are invalid for this experiment.


### 4.2.2. Chinese Word Splitting

After years of research on Chinese word separation technology, word separation algorithms can be summarized into the following three types: lexicon-based word separation algorithms, statistical-based word separation algorithms, and semantic understanding-based word separation algorithms. At present, the main popular Chinese word separation systems are Jieba word separation system, THULAC word separation tool, and PkuSeg word separation tool. In this study, PkuSeg is used to classify text. This study adopts the tourism domain model of PkuSeg to classify the text data.


### 4.2.3. Deactivation Words

In text sentiment analysis, tone words and exclamations indicate the degree of sentiment and contribute to text sentiment analysis. According to the needs of text sentiment analysis in this study, the deactivation word list of HIT and the deactivation word list of Baidu are reintegrated.


## 4.2.1. Normative Text

The Chinese catechism comment dataset collected in this study comes from different periods and different platforms, and the encoding format of the text data saved is unified as UTF-8 for the convenience of later use. Nowadays, each platform supports various symbols and expression comments, and in the experiment of this study, we mainly focus on Chinese text for sentiment analysis, so we need to remove the content and symbols in the text data that are invalid for this experiment.


## 4.2.2. Chinese Word Splitting

After years of research on Chinese word separation technology, word separation algorithms can be summarized into the following three types: lexicon-based word separation algorithms, statistical-based word separation algorithms, and semantic understanding-based word separation algorithms. At present, the main popular Chinese word separation systems are Jieba word separation system, THULAC word separation tool, and PkuSeg word separation tool. In this study, PkuSeg is used to classify text. This study adopts the tourism domain model of PkuSeg to classify the text data.


## 4.2.3. Deactivation Words

In text sentiment analysis, tone words and exclamations indicate the degree of sentiment and contribute to text sentiment analysis. According to the needs of text sentiment analysis in this study, the deactivation word list of HIT and the deactivation word list of Baidu are reintegrated.


## 4.3. Experimental Results

It must be numericalized to supply plain language to machine learning algorithms for processing. In today’s natural language processing jobs, the word vector technique is a common method. The Skip-gram model of the word2vec tool is used to train the word vectors in this part, and the Chinese Wikipedia corpus is used as the corpus for word vector training in this article. Since the Chinese Wikipedia corpus contains a large number of traditional Chinese characters, it is necessary to convert traditional Chinese characters to simplified Chinese characters before use.word2vec word vector training process parameters are set as displayed in Table 2.Table 2
Word2vec word embedding training process parameter setting.
ParameterValueParameter descriptionSg1Skip-gram model selected for trainingVector_size300Word vector dimensionWindow5Window sizeMin count10Words with less than 10 times word frequency are discardedThe main parameters used in the experiments in this article are displayed in Table3.Table 3
Hyperparameter configuration.
Network parametersTake valuef1η0.001batch_size32hidden_units256dropout0.1, 0.2, 0.3, 0.4, 0.5epoch1, 5, 10, 15, 20


### 4.3.1. OptimizingEpoch Parameters

In deep learning-based model training, anepoch represents a complete deep learning training. In the actual training of the model, the quantity of iterations of model training has significant effects on the behavior of the model. A small quantity of model iterations will not allow the model to be fully trained and achieve better performance; too many model iterations will make the trained model overfitting and unable to be used for other datasets, which degrades the capability of the model to generalize. According to the epoch parameters in Table 3, several experiments were conducted, and the results of the experiment are shown in Table 4.Table 4
Epoch experiment results.
EpochAccuracyLoss rate10.80630.425950.82130.3989100.85380.3174150.88870.2874200.88640.2885From the results of the experiments with differentepochs in Table 4, the accuracy of the model increases first and then decreases, and the loss of the model decreases first and then increases when the epoch is gradually increased. The most accurate value of 0.887 was achieved for the model and the loss of the model reaches the minimum value of 0.2874 at the 15th epoch of training, and the accuracy and loss of the model change less after the 15th epoch, indicating that the model has converged.


### 4.3.2. OptimizingDropout Parameters

Thedropout algorithm allows the model to be trained in such a way that the activation value of a neuron is suspended with a specific probability and does not rely too much on some unimportant local features, allowing the model to be more generalized. Several experiments were conducted according to the dropout parameters in Table 3, and the performance of the test is given in Table 5.Table 5
Dropout experiment results.
DropoutAccuracyLoss rate0.10.86880.31210.20.87520.30370.30.88640.28850.40.88970.28120.50.89120.2805According to the results of different dropout experiments in Table5, the accuracy of the model is higher when the dropout value is 0.5. The accuracy of the model is higher when the dropout value is 0.5.A contrast analysis experiment with other text sentiment analysis methods was designed on the obtained dataset to evaluate the validity of the text sentiment analysis method suggested in this work, and the experimental results are shown in Table6.Table 6
Experimental results.
ModelsPrecisionRecallFl scoreText CNN0.87380.85490.8643LSTM0.88200.83020.8553BiLSTM0.85750.89630.8765SA-BiLSTM0.87730.89910.8854By comparing the experimental results of LSTM and BiLSTM, the F1 score of BiLSTM outperforms the F1 score of LSTM in both datasets due to the addition of backward long- and short-term memory network in BiLSTM, which can capture both forward and backward semantic dependencies.By making a cross-comparison of the results of BiLSTM and SA-BiLSTM experiments, the combination of self-attentive mechanism and bidirectional long- and short-term memory network constitutes a new model that can fast detect significant features of sparse data, and the F1 score of SA-BiLSTM is higher than the F1 score of BiLSTM.The comparative analysis of the above experiments further confirms that the SA-BiLSTM model presented in this article could obtain superior outcomes in text sentiment analysis.


## 4.3.1. OptimizingEpoch Parameters

In deep learning-based model training, anepoch represents a complete deep learning training. In the actual training of the model, the quantity of iterations of model training has significant effects on the behavior of the model. A small quantity of model iterations will not allow the model to be fully trained and achieve better performance; too many model iterations will make the trained model overfitting and unable to be used for other datasets, which degrades the capability of the model to generalize. According to the epoch parameters in Table 3, several experiments were conducted, and the results of the experiment are shown in Table 4.Table 4
Epoch experiment results.
EpochAccuracyLoss rate10.80630.425950.82130.3989100.85380.3174150.88870.2874200.88640.2885From the results of the experiments with differentepochs in Table 4, the accuracy of the model increases first and then decreases, and the loss of the model decreases first and then increases when the epoch is gradually increased. The most accurate value of 0.887 was achieved for the model and the loss of the model reaches the minimum value of 0.2874 at the 15th epoch of training, and the accuracy and loss of the model change less after the 15th epoch, indicating that the model has converged.


## 4.3.2. OptimizingDropout Parameters

Thedropout algorithm allows the model to be trained in such a way that the activation value of a neuron is suspended with a specific probability and does not rely too much on some unimportant local features, allowing the model to be more generalized. Several experiments were conducted according to the dropout parameters in Table 3, and the performance of the test is given in Table 5.Table 5
Dropout experiment results.
DropoutAccuracyLoss rate0.10.86880.31210.20.87520.30370.30.88640.28850.40.88970.28120.50.89120.2805According to the results of different dropout experiments in Table5, the accuracy of the model is higher when the dropout value is 0.5. The accuracy of the model is higher when the dropout value is 0.5.A contrast analysis experiment with other text sentiment analysis methods was designed on the obtained dataset to evaluate the validity of the text sentiment analysis method suggested in this work, and the experimental results are shown in Table6.Table 6
Experimental results.
ModelsPrecisionRecallFl scoreText CNN0.87380.85490.8643LSTM0.88200.83020.8553BiLSTM0.85750.89630.8765SA-BiLSTM0.87730.89910.8854By comparing the experimental results of LSTM and BiLSTM, the F1 score of BiLSTM outperforms the F1 score of LSTM in both datasets due to the addition of backward long- and short-term memory network in BiLSTM, which can capture both forward and backward semantic dependencies.By making a cross-comparison of the results of BiLSTM and SA-BiLSTM experiments, the combination of self-attentive mechanism and bidirectional long- and short-term memory network constitutes a new model that can fast detect significant features of sparse data, and the F1 score of SA-BiLSTM is higher than the F1 score of BiLSTM.The comparative analysis of the above experiments further confirms that the SA-BiLSTM model presented in this article could obtain superior outcomes in text sentiment analysis.


## 5. Conclusions

Teaching and promoting Chinese as a foreign language currently present both opportunities and obstacles. On the one hand, the global “Chinese language fever” continues to spread, while on the other hand, the sharing of high-quality international Chinese education resources and the development of convenient and efficient Chinese learning resources have emerged as critical issues that must be addressed urgently in the teaching and promotion of the Chinese language. In this context, giving full play to the advantages of information technology in the age of artificial intelligence to promote the reform and innovation of Chinese language teaching and promotion is a new issue that we should actively consider and explore in the new era.Deep learning has made significant contributions in areas such as computer vision, machine translation, and biomedical analysis, and increasingly deep learning methods are also being applied to text sentiment analysis with better results than earlier text sentiment analysis methods. Long- and short-term memory networks are well suited for processing text data because they can capture longer distance dependencies well. The self-attentive mechanism is able to capture the internal structure of a sentence by directly computing dependencies regardless of the distance between words.In this article, we propose a long- and short-term memory network combined with a self-concern mechanism to evaluate the positive and negative evaluation of overseas Chinese catechism courses, in response to the demand for Chinese language promotion in the new period, using deep learning technology in the field of text emotion recognition. We aim to help optimize Chinese language promotion courses and accelerate the process of Chinese language internationalization through an in-depth study of this topic.Although the model technique used in this article has improved the effectiveness of text sentiment analysis, there are still certain flaws that need to be addressed. For example, BERT obtained excellent performance in 11 natural language processing projects, and the most significant strength ofBERT over word2vec and glove word vector models is that it can address the multisense problem. The word vector model in this article can be replaced by BERT in the future.



---

*Source: 7319656-2022-05-23.xml*