A Deep Learning-Based Method for Sentiment Classification of Weibo Texts

By combining GloVe, BERT and SenticNet with CNN and BiGRU models, the problem of insufficient feature extraction in Weibo texts by traditional emotion classification models is solved, and a more accurate and stable emotion classification effect is achieved.

CN115757792BActive Publication Date: 2025-07-25HUNAN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211504882.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-29
Publication Date
2025-07-25
Estimated Expiration
2042-11-29

AI Technical Summary

Technical Problem

When processing Weibo texts, the traditional emotion classification model has poor feature extraction capabilities, cannot effectively handle the polysense and ironic semantics of the word, and does not fully consider the dependence of context information.

Method used

The GloVe and BERT models are used to generate static and dynamic word vectors, combined with the SenticNet dictionary, local and global features are extracted through the CNN and BiGRU models, and emotional dimension distribution is fused, and emotional classification is used by the Softmax classifier.

Benefits of technology

It improves the accuracy and stability of emotional classification of Weibo texts, can better handle the multiple meanings and satirical semantics of the word, and is suitable for emotional classification in multiple fields.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115757792B_ABST
    Figure CN115757792B_ABST
Patent Text Reader

Abstract

The present invention provides a method for sentiment classification of Weibo texts based on deep learning, which includes obtaining the source text of Weibo, preprocessing the text, and simultaneously inputting it into the GloVe pre-trained model and the BERT pre-trained model to generate corresponding word vectors and inputting them into the SenticNet sentiment dictionary to obtain sentiment polarity values. Stack and embed the generated word vectors and simultaneously input them into the CNN and BiGRU to output local feature vectors and global feature vectors, and splice them with the sentiment dimension distribution vector and input them into the fully connected layer. Use the Softmax function for classification, average the obtained sentiment polarity values, and determine the sentiment tendency through a set threshold, so as to solve the problems that the traditional sentiment classification model has poor feature extraction ability and cannot handle polysemy, ironic semantics, etc., and improve the effect of text sentiment classification.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of natural language processing, and particularly to a method for sentiment classification of Weibo texts based on deep learning. Background Art

[0002] Text sentiment analysis refers to the process of analyzing, processing, and extracting subjective texts with emotional colors by using natural language processing and text mining technologies, and has continuously become one of the hot issues in the research fields of natural language processing and text mining in recent years. Sentiment analysis tasks can be divided into sub-problems such as sentiment classification, sentiment retrieval, and sentiment extraction according to the types of tasks they study. Among them, sentiment classification, also known as sentiment tendency analysis, refers to identifying whether the sentiment of the subjective text in a given text is positive or negative.

[0003] Looking at the current research work on sentiment tendency analysis of subjective texts, the main methods are divided into sentiment dictionary methods based on semantics, machine learning-based methods, and deep learning-based methods:

[0004] 1. Sentiment dictionary methods based on semantics. The construction of a sentiment dictionary is the premise and foundation of sentiment classification. In actual use, it is divided into four categories: general sentiment words, degree adverbs, negative words, and domain words. The main methods for constructing sentiment dictionaries at home and abroad are to create them using existing semantic resource vocabularies, regarding the text as a set of words. By formulating rules for language expression and manually annotating the sentiment dictionary, the text is disassembled into paragraphs and syntactic analysis is performed. In terms of English, it is mainly an extension of the Word Net of the English dictionary. The synonym and near-synonym relationships between words in Word Net are used to judge the sentiment tendency of sentiment words, and based on this, the sentiment polarity of the text view is judged. In terms of Chinese, it is mainly an extension of How Net of the Chinese Knowledge Resource. The semantic similarity calculation method is used to calculate the semantic similarity between words and the benchmark sentiment word level, and based on this, the sentiment tendency of the word is judged. In summary, the words in the text are matched with the sentiment dictionary, and the sentiment tendency score of the text is calculated. Its classification effect depends on the quality of the sentiment dictionary and has low universality in different fields.

[0005] 2. Machine learning-based method. By manually annotating the text tendency as the training set, extracting the text sentiment features, constructing a sentiment classifier through machine learning methods, and classifying the text to be classified through the classifier. Commonly used sentiment classification features include sentiment words, part of speech, syntactic structure, negative expression templates, connections, semantic topics, etc., and the methods for feature extraction include Information Gain (IG), Chi-square (CHI) statistic, and Document Frequency (DF), etc. Commonly used classification methods include the central vector classification method, K-Nearest-Neighbor (KNN) classification method, Naive Bayes, Support Vector Machine, Conditional Random Field, Maximum Entropy Classification, Decision Tree, etc. This method requires manual annotation, which is labor-intensive, time-consuming, and the selection of features directly affects the performance of the sentiment analysis task.

[0006] 3. Deep learning-based method. In recent years, deep learning algorithms have been dominating other traditional sentiment analysis methods. These algorithms detect emotions or opinions in text without feature engineering. There are various deep learning algorithms, namely recurrent neural networks and convolutional neural networks, which are applied to sentiment analysis and give more accurate results than those provided by machine learning models. For the sentiment analysis method of Chinese text on social platforms, due to problems such as short texts, polysemy, and sarcastic remarks, it affects the effect of deep learning in extracting text features, thus affecting the effect of sentiment classification. Summary of the Invention

[0007] In view of the above deficiencies or improvement requirements of the prior art, the present invention provides a deep learning-based Weibo sentiment classification method, aiming at the problems that the traditional sentiment classification model has poor feature extraction ability and cannot handle problems such as polysemy and sarcastic semantics. By stacking embedded static word vectors and dynamic word vectors, the text feature extraction method is improved; aiming at the insufficient consideration of the internal dependence relationship of the original information and context information, a CNN and BiGRU are constructed to extract local features and global features in parallel; aiming at the influence of specific words in the text on the text sentiment polarity, the SenticNet dictionary is introduced to calculate the sentiment polarity and sentiment dimension distribution, fuse the features of the text and words, and perform a more fine-grained analysis from four dimensions of sentiment to improve the effect of text sentiment classification.

[0008] According to the first aspect of the present invention, there is provided a deep learning-based Weibo text sentiment classification method, characterized in that the method includes:

[0009] Step 1: Preprocess the Weibo text data, which includes crawling the Weibo text data as the source text, cleaning the source text through regular expressions to remove special symbols and tags, performing Chinese word segmentation on the source text, and using the natural language processing toolkit to remove stop words from the source text to exclude interference features, obtaining text D.

[0010] Step 2: Generate word vectors, which includes converting the words in text D into static word vectors according to the GloVe model Converting the words in text D into dynamic word vectors S according to the BERT model b =[w b1 ,w b2 ,...,w bt , calculating the similarity of the words in text D according to the SenticNet sentiment dictionary, obtaining the first sentiment polarity value P sentic =polarity(w i ) and the sentiment dimension distribution vector S w =[pleasantness w ,attention w ,sensitivity w ,aptitude w , where t is the dimension of the generated word vectors.

[0011] Step 3: Extract feature vectors according to the neural network model, which includes stacking and embedding the static word vectors and the dynamic word vectors S b =[w b1 ,w b2 ,...,w bt to generate input word vectors Inputting the input word vectors into the convolutional neural network to obtain local feature vectors, and inputting the input word vectors into the BiGRU model to obtain global feature vectors.

[0012] Step 4: Text sentiment classification, which includes concatenating the local feature vectors, global feature vectors, and sentiment dimension distribution vectors, inputting them into the fully connected layer for processing, and then inputting them into the Softmax classifier to calculate the sentiment polarity value to obtain the second sentiment polarity value P CNN_BiGRU , averaging the first sentiment polarity value and the second sentiment polarity value to obtain the sentiment polarity value P of text D D , performing sentiment classification judgment according to the preset threshold, and outputting the text sentiment classification result.

[0013] Further, the method for classifying sentiment of Weibo text based on deep learning provided by the present invention is characterized in that step 2 includes:

[0014] Step 2-1: The GloVe model is a word representation tool based on global word frequency statistics. A co-occurrence matrix is constructed according to text D, and the word vector is represented as where each element x ij represents the number of times word i and word j co-occur within a context window of a specific size. According to the distance d between the two words in the context window, the weight is calculated through the attenuation function and the word vector w i is generated through the co-occurrence matrix, and static word vectors are output

[0015] Step 2-2: The BERT model of chinese_L-12_H-768_A-12 is adopted, where the number of Transformer Encoder layers is 12, the dimension of the hidden layer is 768, and the number of self-attention heads in the self-attention mechanism layer is 12. The word vector representation of the input text D is enhanced by the Transformer Encoder layer and the self-attention mechanism layer to fuse the full-text semantic information of the words in text D, and dynamic word vectors S b =[w b1 ,w b2 ,...,w bt .

[0016] Step 2-3: The SenticNet sentiment dictionary is used to calculate the sentiment intensity. SenticNet is a knowledge base at the concept level, providing concepts related to semantics, sentiment, and polarity. Semantics refers to the five concepts most semantically related to the input concept, sentiment refers to the sentiment values of four sentiment dimensions (pleasantness, attention, sensitivity, aptitude), and the sentiment polarity value in the interval [-1, 1]. By inputting the words in text D, the first sentiment polarity value P sentic =polarity(w i ) and the sentiment dimension distribution vector S w =[pleasantness w ,attention w ,sensitivity w ,aptitude w .

[0017] Further, the method for classifying sentiment of Weibo text based on deep learning provided by the present invention is characterized in that step 3 includes:

[0018] Step 3-1: The convolutional layer consists of several feature maps. Each feature map is composed of multiple neurons. The neurons are connected to the previous layer through convolutional kernels. The input Each convolutional kernel corresponds to extracting a certain part of the features, obtaining the feature matrix of that part. Each row in the matrix corresponds to the word vector of a word. When extracting text features, the convolutional kernel performs a convolutional operation from top to bottom. After the convolutional operation is completed, a non-linear mapping is performed on the convolutional result of the convolutional kernel. The ReLU function f = relu = max(0, x) is used as the activation function to obtain the feature matrix Z = f(W * S input + b) = relu(W * S input + b), where W is the weight matrix and b is the bias term. The convolutional layer uses three different sizes of convolutional kernels (Conv2, Conv3, Conv5) to obtain the features between different distance word sequences. The pooling layer extracts the maximum eigenvalue in the pooling area of the feature map through the max pooling method to reduce the dimension of the feature information. Z max = max(Z i ) represents the feature map extracted by the max pooling layer, where Z i represents the i-th feature map Z, and max represents taking the maximum value.

[0019] Step 3-2: The BiGRU model is used to extract the global features of text data, including a reset gate and an update gate. The two gated states are obtained through the previous transmitted state h t-1 and the input S of the current node input-t . At time t in the model, the current hidden layer h t is obtained by weighted summation of the forward hidden layer and the backward hidden layer . The calculation method is as follows:

[0020]

[0021]

[0022]

[0023] Among them, S input-t represents the input of the current hidden layer, represents the forward hidden layer state at time (t - 1), represents the backward hidden layer state at time (t - 1), w t , v t respectively represent the weight value of the previous hidden layer and the weight value of the subsequent hidden layer of the BiGRU model at time t, and b t represents the bias value of the hidden layer state at time t.

[0024] Further, the method for classifying microblog text sentiment based on deep learning provided by the present invention is characterized in that step 4 includes:

[0025] Concatenate the local feature vector Z max , the global feature vector h t and the sentiment dimension distribution vector S w , process through a fully connected layer, and prevent overfitting of the model by fusing the Dropout method before the fully connected layer, and input it into the Softmax classifier for text sentiment classification operation to obtain:

[0026] Y' = Dropout(a * y) + b,

[0027] Y = softmax(Y'),

[0028] where a and b are the weight matrix and bias value of the fully connected layer, y is the concatenated feature vector, and the second sentiment polarity value P CNN_BiGRU = polarity(Y) is output.

[0029] Average P CNN_BiGRU = polarity(Y) and P sentic = polarity(w i ) to obtain the sentiment polarity value of text D Perform sentiment classification judgment according to a preset threshold, and output the text sentiment classification result.

[0030] According to the third aspect of the present invention, there is provided a computer device, characterized in that it includes:

[0031] A memory for storing instructions; and a processor for calling the instructions stored in the memory to execute the method of the first or second aspect.

[0032] According to the fourth aspect of the present invention, there is provided a computer-readable storage medium, characterized in that it stores instructions, and when the instructions are executed by a processor, the method of the first or second aspect is executed.

[0033] Compared with the prior art, the above technical solution conceived by the present invention has at least the following beneficial effects:

[0034] 1. Since the present invention adopts the word embedding methods of the GloVe model and the BERT model, fuses static word vectors and dynamic word vectors, and addresses the problem of polysemy processing in traditional models, the representation of text information can be better adjusted according to the context; and the training speed of the GloVe word embedding method is faster than that of Word2vec.

[0035] 2. Since the present invention extracts local features and global features by simultaneously inputting word vectors into the CNN and BiGRU models, and at the same time combines with the sentiment dimension distribution vectors extracted from the SenticNet dictionary knowledge base related to semantics, sentiment, and polarity, it can better and more comprehensively obtain the features of text data, showing better sentiment classification effects and stability.

[0036] 3. Since the method of the present invention has stability, it is more generally applicable to the sentiment classification of texts.

[0037] It should be understood that the above general description and the following detailed description are only exemplary and explanatory, and cannot limit the present invention. Brief Description of the Drawings

[0038] The drawings herein are incorporated into the specification and constitute a part of this specification, showing embodiments consistent with the present invention, and are used together with the specification to explain the principles of the present invention.

[0039] Figure 1 is a flowchart of a deep learning-based Weibo sentiment classification method shown according to an exemplary embodiment.

[0040] Figure 2 is a flowchart of the stacked embedding of word vectors shown according to an exemplary embodiment.

[0041] Figure 3 is a flowchart of a deep learning-based Weibo sentiment classification method shown according to another exemplary embodiment.

[0042] Figure 4 is a BERT pre-trained model shown according to an exemplary embodiment. Detailed Embodiments

[0043] In order to make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention. In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.

[0044] The present invention provides a deep learning-based Weibo sentiment classification method, as Figure 1 shown, including steps 1-4, specifically as follows:

[0045] Step 1: Preprocess the Weibo text data, which includes crawling the Weibo text data as the source text, cleaning the data of the source text through regular expressions to remove special symbols and tags, performing Chinese word segmentation on the source text, and using the natural language processing toolkit to remove stop words from the source text to exclude interference features and obtain text D.

[0046] Among them, obtain the source text, preprocess the text, obtain Weibo data, preprocess the text, including tokenization, stop word removal, POS tagging, etc.

[0047] In Step 1, crawl the Weibo data from Sina Weibo as the source text, clean the data through regular expressions to remove special symbols and useless tags, then perform Chinese word segmentation on it using the jieba word segmentation tool, and use the natural language processing toolkit to perform preprocessing operations such as stop word removal to exclude interference features and reduce the complexity for subsequent processing, and obtain text D.

[0048] Step 2: Generate word vectors, which includes converting the words in text D into static word vectors according to the GloVe model Converting the words in text D into dynamic word vectors S according to the BERT model b =[w b1 ,w b2 ,...,w bt , calculating the similarity of the words in text D according to the SenticNet sentiment dictionary to obtain the first sentiment polarity value P sentic =polarity(w i ) and the sentiment dimension distribution vector S w =[pleasantness w ,attention w ,sensitivity w ,aptitude w , where t is the dimension of the generated word vectors.

[0049] Map the text or words obtained in Step 1 to real-valued vectors, represent words with the same semantics or related to each other as similar vectors, so that the machine can understand that the vector representation of "queen" + "female" + "male" is the same as the vector representation of "king". The word vector method uses the GloVe model and the BERT model respectively to generate corresponding static word vectors and dynamic word vectors. Input the text words into the SenticNet sentiment dictionary to generate the corresponding sentiment polarity value and sentiment dimension distribution vector.

[0050] Step 3: Extract feature vectors according to the neural network model, which includes the static word vectors and the dynamic word vector Sb = [w b1 , w b2 ,..., w bt Stacked embedding to generate input word vectors The input word vectors are input into a convolutional neural network to obtain local feature vectors. The input word vectors are input into a BiGRU model to obtain global feature vectors;

[0051] Step 4: Text sentiment classification, which includes concatenating the local feature vectors, global feature vectors, and sentiment dimension distribution vectors, inputting them into a fully connected layer for processing, and then inputting them into a Softmax classifier to calculate the sentiment polarity value to obtain the second sentiment polarity value P CNN_BiGRU , averaging the first sentiment polarity value and the second sentiment polarity value to obtain the sentiment polarity value P of text D D , making a sentiment classification judgment according to a preset threshold, and outputting the text sentiment classification result.

[0052] The purpose of the present invention is to improve the feature extraction method of text by stacking and embedding static word vectors and dynamic word vectors for the problems that traditional sentiment classification models have poor feature extraction capabilities and cannot handle polysemy, sarcastic semantics, etc.; for the problem of not fully considering the internal dependence relationship of the original information and context information, constructing CNN and BiGRU to extract local features and global features in parallel; for the influence of specific words in the text on the text sentiment polarity, introducing the SenticNet dictionary to calculate the sentiment polarity and sentiment dimension distribution, fusing the features of the text and words, and performing a more fine-grained analysis from four dimensions of sentiment to improve the effect of text sentiment classification.

[0053] In some embodiments, the word vector method in step 2 is generated using GloVe, BERT models, and SenticNet, and specifically includes:

[0054] Step 2-1: GloVe is a word representation tool based on global word frequency statistics. A co-occurrence matrix is constructed according to the preprocessed text D, and the word vector is represented as where each element x ij represents the number of times word i and word j co-occur within a context window of a specific size, and can capture some semantic characteristics between words. Since the word vector is affected by the distance between words, according to the distance d between two words in the context window, a decay function is used to calculate the weight, so that the weights of the counts of two words that are farther apart are smaller. Word vectors w i are generated through the co-occurrence matrix, and static word vectors are output

[0055] Step 2-2: The BERT (Bidirectional Encoder Representations from Transformers) model, as Figure 4 shown, is pre-trained through two tasks: Masked LM and Next Sentence Prediction. The chinese_L-12_H-768_A-12 is adopted, that is, the number of Transformer Encoder layers is 12, the dimension of the hidden layer is 768, and the number of self-attention heads is 12. Through the word vector representation of the input text, the Transformer Encoder and the self-attention mechanism layer enhance the vector representation of the full text semantics of the words and phrases in the text, and output the dynamic word vector S b =[w b1 ,w b2 ,...,w bt 。

[0056] Step 2-3: The SenticNet sentiment dictionary is used to calculate the sentiment intensity. SenticNet is a knowledge base at the concept level, providing concepts related to semantics, sentiment, and polarity. Semantics refers to the five concepts most semantically relevant to the input concept, sentiment refers to the sentiment values of four sentiment dimensions (pleasantness, attention, sensitivity, aptitude), and the sentiment polarity value in the interval [-1,1]. SenticNet can be downloaded as an independent XML file, obtained through the API, or called as a third-party Python library. By inputting the words and phrases in the text D, the sentiment polarity value P sentic =polarity(w i ) and the sentiment dimension distribution vector S w =[pleasantness w ,attention w ,sensitivity w ,aptitude w 。

[0057] In some embodiments, in Step 3, the static word vectors and the dynamic word vector S b =[w b1 ,w b2 ,...,w bt obtained in Step 2 are stacked and embedded to generate the input word vector as Figure 2 shown. The input word vector The local features of the input information are obtained by inputting into a Convolutional Neural Network (CNN). It uses convolutional kernels in the convolutional layer to perform convolutional abstraction operations on the input word vectors, transforming the original word vector sequence into an abstract meaning sequence after convolution, that is, the local feature vectors. Then, it is input into the max-pooling layer for feature dimensionality reduction, retaining the significant feature vectors, reducing the data volume, thereby reducing the parameters and the computational amount. The input word vectors are input into a Bidirectional Gated Recurrent Unit (BiGRU) to obtain the global features of the input information, which considers the context information and outputs the global feature vectors.

[0058] Specifically, a dual-channel of CNN and BiGRU is constructed, and the input word vectors are input into the CNN and BiGRU to obtain the local feature vectors and global feature vectors of the input information:

[0059] Step 3-1: The CNN consists of two parts, the convolutional layer and the pooling layer:

[0060] The convolutional layer is composed of several feature maps. Each feature map consists of multiple neurons. The neurons are connected to the previous layer through convolutional kernels. The input Each convolutional kernel corresponds to extracting a certain part of the features, obtaining the feature matrix of that part. Each row in the matrix corresponds to the word vector of a word. When extracting text features, the convolutional kernel performs convolutional operations from top to bottom. After the convolutional operation is completed, a non-linear mapping is performed on the convolutional result of the convolutional kernel to obtain the feature matrix Z as shown in the formula:

[0061] Z = f(W * S input + b),

[0062] where W is the weight matrix and b is the bias term.

[0063] A non-linear mapping is performed on the convolutional result of each convolutional kernel in the CNN. Generally, the ReLU function is used as the activation function, as shown in the formula:

[0064] f = relu = max(0, x),

[0065] Therefore, the feature matrix Z can be expressed by the formula:

[0066] Z = f(W * S input + b) = relu(W * S input + b),

[0067] The convolutional layer uses three different sizes of convolutional kernels (Conv2, Conv3, Conv5) to obtain the features between word sequences at different distances, so as to extract local features more comprehensively.

[0068] The pooling layer extracts the maximum eigenvalue in the pooling region of the feature map through the max pooling method, which can reduce the dimensionality of the feature information, Z max represents the feature map extracted by the max pooling layer, as shown in the following formula:

[0069] Z max = max(Z i ),

[0070] where Z i represents the i-th feature map Z, and max represents taking the maximum value.

[0071] Step 3-2: The BiGRU model is used to extract the global features of the text data, including a reset gate and an update gate. The two gated states are obtained through the previous transmitted state h t-1 and the input S input-t of the current node. At time t in the model, the current hidden layer h t is obtained by the weighted sum of the forward hidden layer and the backward hidden layer , and the specific calculation is as follows:

[0072]

[0073]

[0074]

[0075] where S input-t represents the input of the current hidden layer, represents the forward hidden layer state at time (t-1), represents the backward hidden layer state at time (t-1), w t , v t respectively represent the relevant weight values of the pre-hidden layer and the post-hidden layer corresponding to the BiGRU at time t, and b t represents the bias value of the hidden layer state at time t.

[0076] In some embodiments, in step 4, the local feature vector Z max , the global feature vector h t and the sentiment dimension distribution vector S w obtained in step (2) are concatenated, processed through a fully connected layer, and the Dropout method is fused before the fully connected layer to prevent the model from overfitting. It is input into a Softmax classifier for text sentiment classification operation, and the formula is as follows:

[0077] Y' = Dropout(a * y) + b,

[0078] Y = soft max(Y')

[0079] Among them, a and b are the weight matrix and bias value of the fully connected layer, y is the concatenated feature vector, and the output sentiment polarity value P CNN_BiGRU = polarity(Y).

[0080] The obtained sentiment polarity value P CNN_BiGRU = polarity(Y) and the polarity value P obtained from the SenticNet sentiment dictionary in step (2) sentic = polarity(w i ) are averaged as follows:

[0081]

[0082] Finally, the sentiment polarity value P of the output text D is used to determine the sentiment tendency through a threshold.

[0083] In summary, the present invention provides a method for classifying microblog text sentiment based on deep learning, and its process is as Figure 3 shown:

[0084] (1) Obtain the microblog source text, preprocess the text, and generate text D;

[0085] (2) Input text D into the GloVe pre-trained model and the BERT pre-trained model at the same time, and generate corresponding word vectors and S b = [w b1 , w b2 ,..., w bt , input text D into the SenticNet sentiment dictionary, and obtain the sentiment polarity value P sentic and S w ;

[0086] (3) Stack and embed the generated word vectors to obtain the input word vector and input it into CNN and BiGRU at the same time, and output the corresponding local feature vector Z max and the global feature vector h t ;

[0087] (4) Concatenate the local feature vector Z max , the global feature vector h t and the sentiment dimension distribution vector S w , input it into the fully connected layer, and then use the Softmax function for classification to obtain the sentiment polarity value P CNN_BiGRU , and for P CNN_BiGRU and P senticPerform mean processing and output the emotional polarity value P of the text D , determine the emotional tendency through the set threshold, and obtain the final result of emotional classification.

[0088] Those skilled in the art will readily conceive of other embodiments of the present invention after considering the specification and practicing the invention disclosed herein. This application is intended to cover any variations, uses, or adaptations of the present invention, which follow the general principles of the present invention and include known common knowledge or conventional technical means in the technical field not disclosed in this disclosure. The specification and examples are only regarded as exemplary, and the true scope and spirit of the present invention are pointed out by the following claims.

[0089] It should be understood that the present invention is not limited to the exact structures described above and shown in the drawings, and various modifications and changes can be made without departing from its scope. The scope of the present invention is only limited by the appended claims.

Claims

1. A method for sentiment classification of Weibo text based on deep learning, characterized in that, The method includes: Step 1: Preprocess the Weibo text data, which includes crawling the Weibo text data as the source text, cleaning the data of the source text through regular expressions, removing special symbols and tags, performing Chinese word segmentation on the source text, and using a natural language processing toolkit to remove stop words from the source text to exclude interference features and obtain text D; Step 2: Generate word vectors, including converting the words in text D into static word vectors according to the GloVe model , converting the words in text D into dynamic word vectors according to the BERT model , calculating the similarity of the words in text D according to the SenticNet sentiment dictionary to obtain the first sentiment polarity value and the sentiment dimension distribution vector , where is the dimension of the generated word vectors; Step 3: Extract feature vectors according to the neural network model, including stacking the static word vector and the dynamic word vector to generate the input word vector , inputting the input word vector into the convolutional neural network to obtain local feature vectors, and inputting the input word vector into the BiGRU model to obtain global feature vectors; Step 4: Text sentiment classification, which includes concatenating the local feature vector, the global feature vector, and the sentiment dimension distribution vector, inputting them into a fully connected layer for processing, and then inputting them into a Softmax classifier to calculate the sentiment polarity value to obtain the second sentiment polarity value , averaging the first sentiment polarity value and the second sentiment polarity value to obtain the sentiment polarity value of text D , performing sentiment classification judgment according to a preset threshold, and outputting the text sentiment classification result.

2. The method for sentiment classification of Weibo text based on deep learning according to claim 1, wherein The said step 2 includes: Step 2-1: The GloVe model is a word representation tool based on global word frequency statistics. A co-occurrence matrix is constructed according to text D, and the word vector is represented as , where each element represents the number of times word and word co-occur within a context window of a specific size. According to the distance between two words in the context window, the weight is calculated through an attenuation function , and word vectors are generated through the co-occurrence matrix, and static word vectors are output; Step 2-2: Use the BERT model of chinese_L-12_H-768_A-12, where the number of Transformer Encoder layers is 12, the dimension of the hidden layer is 768, the number of self-attention heads in the self-attention mechanism layer is 12. The word vector representation of the input text D is enhanced with the full-text semantic information of the words in the text D through the Transformer Encoder layer and the self-attention mechanism layer, and the dynamic word vector is output ; Step 2-3: The SenticNet sentiment dictionary is used to calculate the sentiment intensity. SenticNet is a knowledge base at the concept level that provides concepts related to semantics, sentiment, and polarity. Semantics refers to the five concepts that are semantically most relevant to the input concept. Sentiment refers to the sentiment values of the four sentiment dimensions of pleasantness, attention, sensitivity, and aptitude, as well as the sentiment polarity value in the range [-1, 1]. By inputting the words in text D, the first sentiment polarity value is obtained and the sentiment dimension distribution vector .

3. The method for sentiment classification of Weibo texts based on deep learning according to claim 2, wherein The said step 3 includes: Step 3-1: The convolutional layer consists of several feature maps. Each feature map is composed of multiple neurons. The neurons are connected to the previous layer through convolutional kernels. The input , and each convolutional kernel corresponds to extracting a certain part of the features to obtain the feature matrix of that part. Each row in the matrix corresponds to the word vector of a word. When extracting text features, the convolutional kernel performs a convolutional operation from top to bottom. After the convolutional operation is completed, a non-linear mapping is performed on the convolutional result of the convolutional kernel, and the ReLU function is used as the activation function to obtain the feature matrix , where is the weight matrix, is the bias term. The convolutional layer uses three different sizes of convolutional kernels, Conv2, Conv3, and Conv5, to obtain the features between word sequences at different distances. The pooling layer extracts the largest eigenvalue in the pooling area of the feature map through the max pooling method to reduce the dimensionality of the feature information, represents the feature map extracted by the max pooling layer, where represents the th feature map , and max represents taking the maximum value; Step 3-2: The BiGRU model is used to extract the global features of text data, including a reset gate and an update gate, and obtains the two gated states through the state transmitted from the previous layer and the input of the current node to obtain the two gated states. In the model the current hidden layer at time t is obtained by weighted summation of the forward hidden layer and the backward hidden layer The calculation method is as follows: ; ; ; Among them, represents the input of the current hidden layer, represents the forward hidden layer state at time t-1, represents the backward hidden layer state at time t-1, 、 respectively represent the weight values of the pre-hidden layer and the post-hidden layer of the BiGRU model at time represents the bias value of the hidden layer state at time 4. The method for sentiment classification of Weibo text based on deep learning according to claim 3, wherein The said step 4 includes: Concatenate the local feature vector , the global feature vector , and the sentiment dimension distribution vector . After processing through a fully connected layer and fusing the Dropout method before the fully connected layer to prevent overfitting of the model, input it into the Softmax classifier for text sentiment classification operation to obtain: ; ; Among them, , are the weight matrix and bias value of the fully connected layer, is the concatenated feature vector, and the second sentiment polarity value is output; Average and to obtain the sentiment polarity value of text D , and make a sentiment classification judgment according to a preset threshold, and output the text sentiment classification result.

5. A computer device, characterized in that, including: a memory for storing instructions; and a processor for calling the instructions stored in the memory to execute the deep learning-based Weibo text sentiment classification method according to any one of claims 1-4.

6. A computer-readable storage medium, characterized in that, Instructions are stored, and when the instructions are executed by the processor, the deep learning-based Weibo text sentiment classification method according to any one of claims 1-4 is executed.

Citation Information

Patent Citations

  • Text sentiment classification method

    CN112818123A

  • Knowledge enhancement-based dual-channel sentiment analysis method, device and equipment

    CN115204183A