Social comment emotion interpretable recognition method and system
By using SVM to screen key feature words in sentiment analysis and combining the dual-branch combination network DCN for analysis, the accuracy and interpretability of sentiment analysis of Chinese social media comments was solved, achieving higher recognition accuracy and transparency.
Patent Information
- Application Number
- CN202411648011.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-18
- Publication Date
- 2025-04-04
- Estimated Expiration
- 2044-11-18
AI Technical Summary
The prior art faces challenges such as low accuracy and lack of interpretability when conducting sentiment analysis of Chinese social media comments, especially when dealing with buzzwords and time-changing vocabulary, the model's recognition effect is poor.
The support vector machine (SVM) algorithm is used to filter out key feature words and build a dynamic feature lexicon. Then, through the dual-branch combination network DCN, combining the keyword feature extraction network and the keyword sequential feature network, sentiment analysis of short comments on social media is carried out to achieve word-level and sentence-level interpretability.
The accuracy and transparency of emotion recognition are improved, and the logic and basis of emotion recognition are revealed through the correlation model output and feature words and keyword word order, which enhances the credibility and interpretability of the model.
Smart Images

Figure CN119761360A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of natural language processing and sentiment analysis, and specifically relates to a sentiment recognition method and system based on Chinese social media comments. Background Art
[0002] With the development of social media, the text data generated by users has increased dramatically, and these data contain rich emotional information. These data contain information such as users' evaluations, attitudes, and emotions on various topics, events, products, services, and brands. These information are of great value for analyzing users' needs, preferences, satisfaction, and loyalty. On the other hand, a large amount of information with personal emotions spreads, ferments, gathers, and collides in social software, forming group emotions and reacting to the real society. These emotional information has infectiousness and communication power, and can affect the emotional attitudes and behavioral tendencies of other users, thus forming emotional resonance, emotional polarization, and emotional induction in social software. At the same time, emotional information in social software can also be fed back to the real society, triggering social hot spots, social problems, social crises, etc., and have an important impact on social stability and social governance. Therefore, it is very important to identify the emotions of social software comments.
[0003] However, due to the particularity of Chinese text, such as semantic ambiguity and the continuous emergence of new words on the Internet, sentiment analysis on it faces many challenges. Specifically, there are a large number of popular words and emoticons in the comments of online social software. These words often have unique emotional meanings and change over time, which makes it difficult for the model to recognize them. Therefore, to perform sentiment analysis on the comments of social software, it is necessary to continuously update and expand the sentiment dictionary and knowledge base, as well as design and optimize models that can process multimodal data. The sentences or comments on social platforms are more colloquial and are mostly short texts, making it difficult to obtain contextual semantic information. Some sequence models based on contextual logical relationships are difficult to play a good role. It is necessary to achieve sentiment recognition only through feature words and the word order of feature words. The language structure of different languages is quite different. Based on the special expression habits of the Chinese language, some foreign irony methods cannot be directly used in Chinese irony recognition. There is a lack of interpretability of the language model, and it is impossible to associate the recognition results of deep learning with feature words. At present, most sentiment analysis models are based on deep learning methods, using a large amount of labeled data for training and prediction, but these models are often a black box, and it is difficult to understand their internal working mechanism and logic. For example, the model gives the sentiment polarity of a comment, but cannot explain which words or phrases influenced this judgment, nor how these words or phrases were combined and calculated. This leads to problems with the interpretability and credibility of the model, and it is impossible to effectively evaluate and improve the model's results. Summary of the invention
[0004] Purpose of the invention: In order to overcome the deficiencies in the prior art, the present invention proposes a method and system for interpretable recognition of social comment emotions, which can not only improve the accuracy of emotion recognition, but also improve the transparency of recognition results through an interpretable analysis framework.
[0005] Technical solution: To achieve the above purpose, the technical solution adopted by the present invention is:
[0006] A social comment sentiment interpretable recognition method includes the following steps:
[0007] Step 1: Collect and process social comment data.
[0008] Step 2: Use the support vector machine (SVM) algorithm to train the preprocessed data set to obtain a trained SVM model.
[0009] Step 3: After the SVM model training is completed, the support vector is obtained and checked to identify the key feature words for emotion judgment.
[0010] Step 4: Establish a dual-branch combined network DCN to perform sentiment analysis on short social media comments based on the identified key feature words to achieve word-level and sentence-level interpretability.
[0011] Preferably: the dual-branch combination network DCN includes a keyword feature extraction network KWFEN, a keyword sequence feature network KWOFEN, a feature fusion unit and a sentiment analysis unit. The keyword feature extraction network KWFEN is used to extract feature word information in a sentence based on the identified key feature words to obtain sentence keyword features. The keyword sequence feature network KWOFEN is used to obtain the embedding of feature words in the comment sentence and their position embedding through an attention mechanism, thereby obtaining sentence keyword sequence features. The feature fusion unit is used to fuse sentence keyword features and sentence keyword sequence features to obtain a fused feature vector. The sentiment analysis unit is used to analyze the fused feature vector to determine whether the emotion carried by the sentence is positive or negative.
[0012] Preferably: the keyword feature extraction network KWFEN includes a sentence input module, a bag-of-words model, a 3-layer convolution pooling layer, and a compression layer connected in sequence, and the feature graph after convolution and pooling is flattened to obtain a sentence keyword feature representing the feature word information in the input sentence. The keyword sequence feature network KWOFEN includes a sentence input module, a fully connected layer, an attention mechanism module, a global average pooling 1D module, and a word order feature module connected in sequence.
[0013] Preferably: the keyword feature extraction network KWFEN uses the key feature words identified by the SVM model as a vocabulary to construct a bag-of-words model, and uses one-hot encoding to encode each sentence to identify whether each sentence contains a feature word.
[0014] k=[k1,k2,k3,…,k j ]
[0015] Among them, k is the vocabulary, j is the number of selected feature words, and if the comment contains the feature word, the corresponding feature word is in the vocabulary. j is 1, and the rest are all 0.
[0016] Preferred: The keyword sequence feature network KWOFEN obtains the embedding of feature words in the comment sentence and their position embedding through the attention mechanism, and then obtains the method of sentence keyword sequence feature:
[0017] First, the sentence is segmented, and then the position codes of different feature words are calculated. When calculating the position codes, the basic sine-cosine position codes are combined with the time decay term and the convolution term to calculate the position codes in a hierarchical combination:
[0018]
[0019] Among them, PE j represents the position encoding of the jth word, i is the index of the position embedding dimension, λ is an adjustable parameter, and d model is the size of the embedding dimension, W conv is the convolution kernel weight, b conv is the bias term, * indicates the convolution operation;
[0020] The attention mechanism module is then used to extract the important features of the word vector and the position-encoded matrix to achieve feature extraction of the keyword word order; the attention mechanism module is used to discover the relationship between the word embedding and position embedding matrices, and then express whether there is a fixed sentence pattern between the keywords:
[0021] Q i =[Q1,Q2,Q3,…,Q i ]
[0022] K j =[K1,K2,K3,…,K j ]
[0023] Where Q i and K j They are the hidden vectors learned by two neural networks through word embedding and position embedding;
[0024] Calculate each Q i and Kj Get the attention weight matrix;
[0025]
[0026] Among them, A i,j represents the element in the i-th row and j-th column of the attention weight matrix, are the linear transformation matrices of the feature words and position embeddings of the h-th head, H represents the number of attention heads, and d k is the dimension of position embedding, b i,j is the bias term.
[0027] Preferably: the method for the feature fusion unit to obtain the fused feature vector is:
[0028] The feature word vector is:
[0029] WF=[wf1,wf2,wf3,…,wf i ]
[0030] Among them, WF is the feature word vector, i is the dimension of the feature extraction network output, and is the vector representation of the feature word of the comment.
[0031] The word order vector is:
[0032] SF=[sf1,sf2,sf3,…,sf j ]
[0033] Among them, SF is the word order vector, j is the dimension of the keyword word order feature extraction network output, and is the vector representation of the comment keyword order.
[0034] The two vectors are concatenated to form a complete fusion feature vector CF and sent to the neural network for emotion recognition:
[0035] CF=[wf1,wf2,wf3,…,wf i ,sf1,sf2,sf3,…,sf j ]
[0036] Among them, CF is the fused feature vector.
[0037] Preferably, the emotion analysis unit is used to perform emotion binary classification recognition based on the fused feature vector, and then activate the sigmoid function to obtain the probability of the emotion category to which the sentence belongs. Then, according to the probability of the emotion category to which the sentence belongs, it is determined whether the emotion carried by the sentence is positive or negative.
[0038] Preferably: the emotion analysis unit determines whether the emotion of the sentence is positive or negative by analyzing the fused feature vector: the feature fused vector is passed to the classification layer, and then input into the sigmoid function, and the classifier is used to perform emotion binary classification recognition on the sentence to be judged, and the calculation formula is:
[0039]
[0040] Among them, f(x) is the probability of the sentiment category to which the sentence belongs, and x is the vector after feature fusion.
[0041] When the probability of the sentence belonging to a certain sentiment category is higher than the set threshold, the sentence is classified as positive sentiment, otherwise it is classified as negative sentiment.
[0042] Preferably, in step 3, the positive support vector is used to filter out the feature words with the strongest positive emotion, and the negative support vector is used to filter out the feature words with the strongest negative emotion. The feature words with the strongest positive emotion and the strongest negative emotion are obtained from the positive support vector and the negative support vector, respectively.
[0043] Preferably: in step 2, the trained SVM model is evaluated by a cross-validation method to test its accuracy and generalization ability. If the evaluation result is not ideal, return to adjust the parameters and retrain.
[0044] Preferred: The method for processing social comment data in step 1: cleaning and organizing the data set, removing noise data and invalid information, removing duplicate content, processing special characters, and performing word segmentation operations.
[0045] A social comment emotion interpretable recognition system includes an information collection and processing unit, a SVM model unit, and a dual-branch combination network DCN unit, wherein:
[0046] The information collection and processing unit is used to collect and process social comment data.
[0047] The SVM model unit uses a support vector machine (SVM) algorithm to train the preprocessed data set to obtain a trained SVM model. After the SVM model training is completed, the support vector is obtained and checked to identify key feature words for emotion judgment.
[0048] The dual-branch combined network DCN unit is used to perform sentiment analysis of short comments on social media through the dual-branch combined network DCN according to the identified key feature words, thereby achieving word-level and sentence-level interpretability.
[0049] Another object of the present invention is to provide a non-transitory computer-readable storage medium, which stores computer instructions, and the computer instructions enable the computer to execute the method for interpretable identification of social comment emotions.
[0050] Another object of the present invention is to provide an electronic device, comprising: at least one processor, at least one memory and a communication interface. The processor, memory and communication interface communicate with each other. The memory stores program instructions that can be executed by the processor, and the processor calls the program instructions to execute the social comment emotion interpretable recognition method.
[0051] Compared with the prior art, the present invention has the following beneficial effects:
[0052] The present invention reveals the logic and basis of emotion recognition by associating model output with feature words and keyword word order, thereby improving the credibility and transparency of the model.
[0053] The chi-square test method is used to calculate the correlation between each feature variable and the result to increase the weight of the features that contribute more to sample classification in the SHAP method, to improve the traditional SHAP method and increase the weight of the features of sample classification under the joint action of multiple feature factors, and to establish a mapping between model weights and input features to perform interpretable analysis on feature word extraction.
[0054] The present invention is applicable to a variety of application scenarios such as public opinion analysis, consumer behavior research, customer service automation, etc. Compared with the prior art, the present invention has significantly improved the accuracy, dynamic adaptability and interpretability of emotion recognition, and has important practical value and theoretical significance in the field of social media data analysis. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] Figure 1 It is a flow chart of the steps of the present invention.
[0056] Figure 2 It is a structural diagram of the keyword feature extraction neural network (KWFEN) of the present invention, which is used to extract keyword information.
[0057] Figure 3 It is a structural diagram of the keyword sequence feature extraction neural network (KWOFEN) of the present invention, which is used to extract keyword word sequence features.
[0058] Figure 4 This is a complete neural network architecture diagram of the present invention. DETAILED DESCRIPTION
[0059] The present invention is further explained below in conjunction with the accompanying drawings and specific embodiments. It should be understood that these examples are only used to illustrate the present invention and are not used to limit the scope of the present invention. After reading the present invention, various equivalent forms of modifications to the present invention by those skilled in the art all fall within the scope defined by the claims attached to this application.
[0060] With the popularity of social media, the comment data generated by users has exploded, which contains rich emotions and opinion information. However, existing emotion recognition methods face challenges such as low accuracy and lack of interpretability. To address these problems, we propose an interpretable recognition method for social comment emotions for sentiment analysis of short comments on social media. The purpose is to perform interpretable analysis of popular words and keyword word order on the model. First, support vector machine (SVM) is used to filter out feature words with emotion-indicating meanings from social comments, and a dynamic feature word library is constructed to adapt to the rapid changes in social media terms. Secondly, by calculating the position encoding of word vectors in sentences and combining with feature word libraries, deep learning models are used to effectively extract emotional features from short texts. In addition, the present invention also proposes an interpretable analysis framework, which reveals the logic and basis of emotion recognition by associating model output with feature words and keyword word order, thereby improving the credibility and transparency of the model and achieving word-level and sentence-level interpretability, such as Figure 1 As shown, the specific steps include:
[0061] Step 1: Collect and process social comment data.
[0062] Collect social comment data, ensure that the data is complete and accurate, and prepare the relevant tools and environment for the support vector machine (SVM) algorithm. Then preprocess the data set, including cleaning and sorting the data set, removing noise data and invalid information. It also includes operations such as removing duplicate content, processing special characters, and word segmentation, so as to better carry out subsequent training.
[0063] Step 2: Use the support vector machine (SVM) algorithm to train the preprocessed data set to obtain a trained SVM model.
[0064] Use the support vector machine (SVM) algorithm to train the preprocessed data set. Adjust appropriate parameters, including kernel function type, penalty coefficient, etc., to obtain the maximum training effect. Then evaluate the trained SVM model through the cross-validation method to test its accuracy and generalization ability. If the evaluation result is not ideal, return to adjust the parameters and retrain.
[0065] The support vector machine (SVM) algorithm extracts feature words from the positive and negative corpus in the data set. First, a complete and accurate data set containing emotional features is prepared and preprocessed to remove invalid information such as noise in the data set. Then, the svm algorithm is used to train the preprocessed data set, and parameters such as the penalty coefficient are adjusted to obtain the best training effect. After that, the trained model is evaluated using methods such as cross-validation to test its accuracy and generalization ability. After the training is completed, its support vector is checked. Finally, the weight or frequency of the feature words in the support vector is calculated to obtain the 20 feature words with the strongest positive and negative emotions.
[0066] Step 3, after the SVM model training is completed, the support vector is obtained and checked to identify which words are the most critical feature words for judging emotions, and a dynamic key feature word library is constructed. The positive support vector is used to filter out the feature words with the strongest positive emotions, and the negative support vector is used to filter out the feature words with the strongest negative emotions. The extracted positive emotion words include "like", "happy", "love", "happy", etc., while the negative emotion words include "sad", "speechless", "uncomfortable", etc. The 20 feature words with the strongest positive and negative emotions are obtained from the positive support vector and the negative support vector respectively. The 20 feature words with the strongest positive and negative emotions are obtained by calculating the weight or frequency of the feature words in the support vector.
[0067] The weight or frequency of the feature words in the support vector is calculated to obtain the feature words with the strongest positive and negative emotions respectively.
[0068] Step 4, establish a dual-branch combination network DCN, which is used to perform sentiment analysis on short comments on social media based on the identified key feature words (dynamic key feature vocabulary) to achieve word-level and sentence-level interpretability. The dual-branch combination network DCN includes a keyword feature extraction network KWFEN, a keyword sequence feature network KWOFEN, a feature fusion unit, and a sentiment analysis unit.
[0069] The data set is trained and feature words are extracted through SVM. For the sample sentences containing positive and negative emotions, the comments after word segmentation are screened by SVM and used to build the subsequent bag-of-words model. The bag-of-words model is constructed with the feature words screened by SVM, and each sentence is encoded using one-hot encoding to distinguish whether each sentence contains feature words, and a keyword feature extraction network KWFEN is used to extract its feature word information. Therefore, the keyword feature extraction network KWFEN uses the feature words screened by the SVM model as a vocabulary to construct the bag-of-words model, and encodes each sentence using one-hot encoding to distinguish whether each sentence contains feature words.
[0070] k=[k1,k2,k3,…,k j ]
[0071] Among them, k is the vocabulary, j is the number of selected feature words, and if the comment contains the feature word, the corresponding feature word is in the vocabulary. j is 1, and the rest are all 0.
[0072] The keyword feature extraction network KWFEN is used to extract the feature word information in the sentence and then obtain the keyword features. The keyword feature extraction network KWFEN includes a sentence input module, a bag of words model, a 3-layer convolution pooling layer, and a compression layer connected in sequence. After the convolution and pooling feature graph is flattened, the sentence keyword features representing the feature word information in the input sentence are obtained, and then wait for fusion with the keyword sequence feature network (KWOFEN).
[0073] The keyword sequence feature network KWOFEN is used to obtain the embedding of feature words in the comment sentence and their position embedding, and then obtain the keyword sequence feature. The keyword sequence feature network KWOFEN includes a sentence input module, a fully connected layer, an attention mechanism module, a global average pooling 1D module, and a word order feature module connected in sequence.
[0074] The keyword sequence feature network KWOFEN is used to obtain the embedding of feature words in the comment sentence and the method of embedding their positions:
[0075] The Keyword Sequential Feature Extraction Network (KWOFEN) first segmented the sentence, then used a combination of sine and cosine functions to calculate the positional encoding of different keywords, and then extracted the important features of the word vector and the positional encoding matrix through attention to achieve feature extraction of the keyword word order. First, the sentence is segmented, and then the positional encoding is calculated for different feature words. When calculating the positional encoding, the basic sine-cosine positional encoding is combined with the time decay term and the convolution term, and the positional encoding is calculated in a hierarchical combination:
[0076]
[0077] Among them, d model is the size of the embedding dimension, and are the basis terms of sine and cosine position encoding, respectively, used to capture the periodicity of position. It is a concatenation operation, which is used to concatenate (or add) the sine-cosine position coding term with the time decay term and the convolution position term to generate a richer position coding vector. j It is a time decay term, which is used to decay the words in the later part of the sequence, simulating the decay phenomenon of information as the sequence position increases, so as to highlight the important information at the front end of the sequence. It is defined as:
[0078]
[0079] Where λ is an adjustable parameter that controls the decay rate.
[0080] C j is the convolution position term, which encodes the sequence position through a one-dimensional convolution operation to strengthen the association between local information and adjacent words. It is defined as:
[0081] C j =W conv *j+b conv
[0082] Where W conv is the convolution kernel weight, b conv is the bias term, and * indicates the convolution operation.
[0083] The position code is:
[0084]
[0085] Among them, PE j represents the position encoding of the jth word, i is the index of the position embedding dimension, λ is an adjustable parameter, and d model is the size of the embedding dimension, W conv is the convolution kernel weight, b conv is the bias term, and * indicates the convolution operation.
[0086] Then, the important features of the word vector and the position-encoded matrix are extracted through attention to realize the feature extraction of keyword word order.
[0087] The feature fusion unit is used to concatenate and fuse the extracted keyword features and keyword sequence features to obtain a fused feature vector.
[0088] Use the deep learning model to obtain the feature word vector and feature word order vector of the extracted sentence and concatenate them.
[0089] The feature word vector is:
[0090] WF=[wf1,wf2,wf3,…,wf i ]
[0091] Among them, WF is the feature word vector, i is the dimension of the feature extraction network output, and is the vector representation of the feature word of the comment.
[0092] The word order vector is:
[0093] SF=[sf1,sf2,sf3,…,sf j ]
[0094] Among them, SF is the word order vector, j is the dimension of the keyword word order feature extraction network output, and is the vector representation of the comment keyword order.
[0095] The two vectors are concatenated to form a complete fusion feature vector CF and sent to the neural network for emotion recognition:
[0096] CF=[wf1,wf2,wf3,…,wf i ,sf1,sf2,sf3,…,sf j ]
[0097] Among them, CF is the fused feature vector.
[0098] The emotion analysis unit is used to perform emotion binary classification recognition based on the fused feature vector, and then activate it through the sigmoid function to obtain the probability of the emotion category to which the sentence belongs. Then, according to the probability of the emotion category to which the sentence belongs, it is determined whether the emotion carried by the sentence is positive or negative.
[0099] The feature fused vector will be passed to the classification layer and then input into the sigmoid function. The classifier is used to perform binary emotion classification on the sentence to be judged. The calculation formula is:
[0100]
[0101] Among them, f(x) is the probability of the sentiment category to which the sentence belongs, and x is the vector after feature fusion.
[0102] When the probability of the sentence belonging to a certain sentiment category is higher than the set threshold, the sentence is classified as positive sentiment, otherwise it is classified as negative sentiment.
[0103] After Sigmoid activation, a scalar value is output, which represents the probability of the sentiment category to which the sentence belongs. When this probability value is higher than the set threshold (such as 0.5), the model will classify the sentence as positive sentiment, otherwise it is negative sentiment.
[0104] Step 5: Establish the connection between model weights and inputs to further perform interpretable analysis on the model. Improve the SHAP method through the chi-square test method to perform interpretable analysis on feature word extraction. At the same time, use the feature word embedding and position embedding extracted by the attention layer to visualize the relationship between them, thereby achieving interpretable analysis of the feature word order.
[0105] The chi-square test method is used to calculate the correlation between each feature variable and the result to increase the weight of the features that contribute more to sample classification in the SHAP method:
[0106]
[0107] Among them, A is the actual frequency, T is the theoretical frequency, and x 2 is the chi-square test value.
[0108] Improve the traditional SHAP method to increase the weight of sample classification features under the joint action of multiple feature factors, establish a mapping between model weights and input features, and perform interpretable analysis on the keyword feature extraction network (KWFEN). Add an attention layer to the neural network that extracts the word order of feature words to discover the relationship between word embedding and position embedding matrices, and then express whether there is a fixed sentence pattern between keywords:
[0109] Q i =[Q1,Q2,Q3,…,Q i ]
[0110] K j =[K1,K2,K3,…,K j ]
[0111] Where Q i and K j are the hidden vectors learned by two neural networks through word embedding and position embedding respectively. i and j represent the maximum length of the comments sent to the model after preprocessing.
[0112] Calculate each Q using the formula i and K j Get the attention weight matrix A.
[0113]
[0114] where d k is the dimension of position embedding, used for scaling to avoid excessive inner product values, b i,j It is a learnable bias term used to adjust the relationship weight between each word and position.
[0115] At the same time, a multi-head mechanism is introduced, and each head corresponds to different feature attention, such as: emotional tendency, context dependence, position relationship, etc.
[0116] α h The weight coefficient of each head is generated through context and can be learned to adjust the importance of different heads in the attention matrix. Dynamically adjust the influence of each head. The calculation formula is as follows:
[0117]
[0118] in is the weight matrix of the h-th head, used to generate weight coefficients. They are the linear transformation matrices of the feature words and positions embedded in the h-th head, mapping the features to a specific subspace so that different heads focus on different features.
[0119] That is, the attention weight matrix is;
[0120]
[0121] Among them, A i,j represents the element in the i-th row and j-th column of the attention weight matrix, are the linear transformation matrices of the feature words and position embeddings of the h-th head, H represents the number of attention heads, and d k is the dimension of position embedding, b i,j is the bias term.
[0122] The length of matrix A is consistent with the length of the comment, which can indirectly reflect the contribution of each position of the comment sent to the model to the model reasoning.
[0123] Combining the interpretable analysis results of both feature words and keyword sequences can effectively help analyze why the model makes inferences and assist in optimizing feature design and model structure.
[0124] By using the chi-square test method to calculate the correlation between each feature variable and the result to increase the weight of the features that contribute more to sample classification in the SHAP method, the traditional SHAP method is improved to increase the weight of the features of sample classification under the joint action of multiple feature factors, and the mapping between the model weights and the input features is established to perform an interpretable analysis of the keyword feature extraction network (KWFEN). An attention layer is added to the neural network that extracts the word order of feature words to discover the relationship between the word embedding and the position embedding matrix, and then express whether there is a fixed sentence pattern between keywords, so as to perform an interpretable analysis of the keyword sequence feature extraction network (KWOFEN).
[0125] In another embodiment, a social comment emotion interpretable recognition system is provided, including an information collection and processing unit, an SVM model unit, and a dual-branch combination network DCN unit, wherein:
[0126] The information collection and processing unit is used to collect and process social comment data.
[0127] The SVM model unit uses a support vector machine (SVM) algorithm to train the preprocessed data set to obtain a trained SVM model. After the SVM model training is completed, the support vector is obtained and checked to identify key feature words for emotion judgment.
[0128] The dual-branch combined network DCN unit is used to perform sentiment analysis of short comments on social media through the dual-branch combined network DCN according to the identified key feature words, thereby achieving word-level and sentence-level interpretability.
[0129] The keyword feature extraction network (KWFEN) is responsible for constructing a bag-of-words model using the feature words selected by SVM as a vocabulary, encoding each sentence using one-hot encoding to identify whether each sentence contains feature words, and then using a three-layer convolutional network to process the sentence input to obtain keyword features and wait for fusion with keyword sequence features. The keyword sequence feature extraction network (KWOFEN) first segments the sentence, and then extracts the keyword word sequence features in the sentence through word embedding and position embedding, combined with a fully connected layer, an attention mechanism, and a pooling layer. Finally, the two features are fused and sent to the neural network for emotion recognition.
[0130] In another embodiment, a non-transitory computer-readable storage medium is provided, wherein the non-transitory computer-readable storage medium stores computer instructions, wherein the computer instructions enable the computer to execute the method for interpretable identification of social comment emotions.
[0131] In another embodiment, an electronic device is provided, comprising: at least one processor, at least one memory and a communication interface. The processor, the memory and the communication interface communicate with each other. The memory stores program instructions executable by the processor, and the processor calls the program instructions to execute the social comment emotion interpretable recognition method.
[0132] The present invention can not only improve the accuracy of emotion recognition, but also improve the transparency of recognition results through an interpretable analysis framework. It is suitable for a variety of application scenarios such as public opinion analysis, consumer behavior research, and customer service automation. Compared with the prior art, the present invention has significantly improved the accuracy, dynamic adaptability, and interpretability of emotion recognition, and has important practical value and theoretical significance in the field of social media data analysis.
[0133] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the principle of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A method for interpretable recognition of social comment sentiment, characterized in that: The following steps are involved: Step 1: Collect and process social comment data; Step 2, using the support vector machine (SVM) algorithm to train the preprocessed data set to obtain a trained SVM model; Step 3: After the SVM model training is completed, the support vector is obtained and checked to identify the key feature words for emotion judgment; Step 4: Establish a dual-branch combined network DCN to perform sentiment analysis on short social media comments based on the identified key feature words to achieve word-level and sentence-level interpretability.
2. The method for interpretable identification of social comment emotions according to claim 1, characterized in that: The dual-branch combined network DCN includes a keyword feature extraction network KWFEN, a keyword sequence feature network KWOFEN, a feature fusion unit and a sentiment analysis unit; the keyword feature extraction network KWFEN is used to extract feature word information in a sentence according to the identified key feature words, thereby obtaining sentence keyword features; the keyword sequence feature network KWOFEN is used to obtain the embedding of feature words in the comment sentence and their position embedding through an attention mechanism, thereby obtaining sentence keyword sequence features; the feature fusion unit is used to fuse sentence keyword features and sentence keyword sequence features to obtain a fused feature vector; the sentiment analysis unit is used to analyze the fused feature vector to determine whether the emotion carried by the sentence is positive or negative.
3. The method for interpretable identification of social comment emotions according to claim 2, characterized in that: The keyword feature extraction network KWFEN includes a sentence input module, a bag-of-words model, a 3-layer convolutional pooling layer, and a compression layer connected in sequence. The feature map after convolution and pooling is flattened to obtain the sentence keyword feature representing the feature word information in the input sentence; the keyword sequence feature network KWOFEN includes a sentence input module, a fully connected layer, an attention mechanism module, a global average pooling 1D module, and a word order feature module connected in sequence.
4. The method for interpretable identification of social comment emotions according to claim 3 is characterized by: The keyword feature extraction network KWFEN uses the key feature words identified by the SVM model as a vocabulary to construct a bag-of-words model, and uses one-hot encoding to encode each sentence to identify whether each sentence contains a feature word; k=[k1,k2,k3,…,k j ] Among them, k is the vocabulary, j is the number of selected feature words, and if the comment contains the feature word, the corresponding feature word is in the vocabulary. j is 1, and the rest are all 0.
5. The method for interpretable identification of social comment emotions according to claim 4 is characterized by: The keyword sequence feature network KWOFEN obtains the embedding of feature words in the comment sentence and their position embedding through the attention mechanism, and then obtains the method of sentence keyword sequence feature: First, the sentence is segmented, and then the position codes of different feature words are calculated. When calculating the position codes, the basic sine-cosine position codes are combined with the time decay term and the convolution term to calculate the position codes in a hierarchical combination: Among them, PE j represents the position encoding of the jth word, i is the index of the position embedding dimension, λ is an adjustable parameter, and d model is the size of the embedding dimension, W conv is the convolution kernel weight, B conv is the bias term, * indicates the convolution operation; The attention mechanism module is then used to extract the important features of the word vector and the position-encoded matrix to achieve feature extraction of the keyword word order; the attention mechanism module is used to discover the relationship between the word embedding and position embedding matrices, and then express whether there is a fixed sentence pattern between the keywords: Q i =[Q1,Q2,Q3,…,Q i ] K j =[K1, K2, K3,…, K j ] Where Q i and K j They are the hidden vectors learned by two neural networks through word embedding and position embedding; Calculate each Q i and K j Get the attention weight matrix; Among them, A i,j represents the element in the i-th row and j-th column of the attention weight matrix, are the linear transformation matrices of the feature words and position embeddings of the h-th head, H represents the number of attention heads, and d k is the dimension of position embedding, B i,j is the bias term.
6. The method for interpretable identification of social comment emotions according to claim 5, characterized in that: The method for the feature fusion unit to obtain the fused feature vector is as follows: The feature word vector is: WF=[wf1,wf2,wf3,…,wf i ] Among them, WF is the feature word vector, i is the dimension of the feature extraction network output, and is the vector representation of the feature word of the comment; The word order vector is: SF=[sf1,sf2,sf3,…,sf j ] Among them, SF is the word order vector, j is the dimension of the keyword word order feature extraction network output, and is the vector representation of the keyword order of the comment; The two vectors are concatenated to form a complete fusion feature vector CF and sent to the neural network for emotion recognition: CF=[wf1,wf2,wf3,…,wf i ,sf1,sf2,sf3,…,sf j ] Among them, CF is the fused feature vector.
7. The method for interpretable identification of social comment emotions according to claim 6, characterized in that: The emotion analysis unit is used to perform emotion binary classification recognition based on the fused feature vector, and then activate it through the sigmoid function to obtain the probability of the emotion category to which the sentence belongs; then determine whether the emotion carried by the sentence is positive or negative based on the probability of the emotion category to which the sentence belongs.
8. The method for interpretable identification of social comment emotions according to claim 7, characterized in that: The emotion analysis unit analyzes the fused feature vector to determine whether the emotion in the sentence is positive or negative: the feature fused vector is passed to the classification layer and then input into the sigmoid function, and the classifier is used to perform emotion binary classification recognition on the sentence to be judged, and the calculation formula is: Among them, f(x) is the probability of the sentiment category to which the sentence belongs, and x is the vector after feature fusion; When the probability of the sentence belonging to a certain sentiment category is higher than the set threshold, the sentence is classified as positive sentiment, otherwise it is classified as negative sentiment.
9. The method for interpretable identification of social comment emotions according to claim 8, characterized in that: In step 3, the positive support vectors are used to filter out the feature words with the strongest positive emotions, and the negative support vectors are used to filter out the feature words with the strongest negative emotions; the feature words with the strongest positive emotions and the strongest negative emotions are obtained from the positive support vectors and the negative support vectors respectively; the trained SVM model is evaluated by the cross-validation method to test its accuracy and generalization ability; if the evaluation result is not ideal, return to adjust the parameters and retrain.
10. A system based on the method for interpretable recognition of social comment emotions according to any one of claims 1 to 9, characterized in that: It includes an information collection and processing unit, an SVM model unit, and a dual-branch combined network DCN unit, wherein: The information collection and processing unit is used to collect and process social comment data; The SVM model unit uses a support vector machine (SVM) algorithm to train the preprocessed data set to obtain a trained SVM model; after the SVM model training is completed, the support vector is obtained and checked to identify key feature words for emotion judgment; The dual-branch combined network DCN unit is used to perform sentiment analysis of short comments on social media through the dual-branch combined network DCN according to the identified key feature words, thereby achieving word-level and sentence-level interpretability.
Citation Information
Patent Citations
Case microblog comment emotion classification method fusing emotion knowledge
CN111324734A
Sentiment analysis method and system for specific target keyword of comment statement
CN114676692A
Social text enhancement method and system based on multi-modal retrieval and keyword extraction
CN115408495A
Emotion-controllable news comment generation method
CN115935975A
Object classification method and related device
CN115994321A