Topic and emotional tendency conjoint analysis method
By combining topic models and graph neural networks in sentiment analysis, we build public opinion feature maps, which solves the problem of ignoring text correlation and topic changes in sentiment analysis, and achieves more accurate sentiment classification and public opinion analysis.
Patent Information
- Application Number
- CN202410862327.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-28
- Publication Date
- 2024-10-01
AI Technical Summary
The existing technology ignores the correlation similarity between texts with the same emotion and the changes in emotions in text topics in sentiment analysis, which affects the model's accurate judgment of emotional tendencies and the study of public opinion trends.
Using methods based on topic models and graph neural networks, text features are extracted through the BERT pre-training model, topic clustering is performed using the LDA model, public opinion feature maps are constructed, and similar text features are fused using graph convolutional neural networks, and the comparative learning module is used for optimization model to improve the accuracy and generalization of emotion classification.
It effectively improves the accuracy of sentiment classification and the generalization ability of the model, enhances the joint analysis ability of public opinion topics and emotional tendencies, and improves the understanding of long text contextual information and the accuracy of topic clustering.
Smart Images

Figure CN118733773A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of natural language processing, and in particular to a method for jointly analyzing public opinion topics and sentiment tendencies based on a topic model and a graph neural network. Background Art
[0002] Sentiment analysis is a method of studying the expression and recognition of human emotions. It accurately identifies the emotional tendencies in text information by analyzing and understanding texts that express human emotions (positive / negative). It is crucial for monitoring patient mental health and analyzing public opinion in social media.
[0003] In recent years, with the development of neural networks, many neural network-based methods have been applied to sentiment analysis tasks, and sentiment analysis technology has also made rapid progress. However, existing methods often use models to learn key information in a given text to determine the emotional tendency expressed by the text.
[0004] The existing technology ignores the correlation similarity between texts with the same sentiment, which will affect the model's accurate judgment of sentiment; and ignores the change of sentiment in the text topic, which will affect the study of the reasons for people's emotional changes and the social media public opinion situation. Therefore, a text sentiment tendency classification method based on text topic and correlation analysis of texts with the same sentiment is needed. Summary of the invention
[0005] In order to solve the problem that similar texts and topics cannot be associated when using models to classify text sentiment, the present invention provides a method for jointly analyzing public opinion topics and sentiment tendencies to improve the accuracy of the model in classifying text sentiment.
[0006] To this end, the present invention provides the following technical solutions:
[0007] The present invention discloses a method for jointly analyzing public opinion topics and sentiment tendencies, comprising:
[0008] Collect and preprocess the public opinion text data to be analyzed to obtain a corpus;
[0009] Encode the text data in the corpus using the BERT pre-trained model to obtain a text feature vector with contextual relationship;
[0010] Input the text feature vector into the LDA model to extract the topic features of the text;
[0011] Using the text feature vector and the topic feature, constructing a public opinion feature graph by calculating text similarity;
[0012] Constructing and training a graph convolutional neural network; the graph convolutional neural network takes the public opinion feature graph as input, fuses feature representations of different texts, learns adjacent node information to update its own node representation, and generates fused features with interactions between similar texts;
[0013] The fusion feature is input into a classifier to obtain the sentiment tendency classification of the text; the sentiment tendency categories include: negative and positive.
[0014] Furthermore, it also includes: optimizing the LDA model by using perplexity calculation.
[0015] Furthermore, the text feature vector and the topic feature are used to construct a public opinion feature graph by calculating text similarity, including:
[0016] Calculating semantic similarity between different nodes in a public opinion graph node set by cosine distance; the public opinion graph node set is composed of the text feature vector;
[0017] When the distance between two nodes is within a specific range, an edge of the semantic relationship between the two points is constructed;
[0018] The text feature nodes and semantic relationship edges are used to construct a public opinion feature graph.
[0019] Furthermore, the graph convolutional neural network is a three-layer graph neural network.
[0020] Furthermore, the loss function used when training the graph convolutional neural network is a contrast loss function.
[0021] Further, training the graph convolutional neural network includes:
[0022] In contrastive learning, data with the same sentiment label in the dataset is classified as positive samples, and others are classified as negative samples; given a small batch of text hidden vectors For a V i ∈H, if V t and V i have the same sentiment label, i.e. y i =y t Then V i Considered to be V t positive example, while other examples V x ∈H is considered a negative example; calculate all positive examples (V t , V i ) and (V i and V t )’s contrast loss:
[0023]
[0024] 1 of them [t≠i]∈(0,1) is the indicator function, sim(V t ,V i ) Calculate the vector V t and V i The cosine similarity of .
[0025] Furthermore, the cross entropy loss function is used as the loss function of the classifier.
[0026] Advantages and positive effects of the present invention:
[0027] 1) By using the graph neural network method, the fusion module updates the feature representation of the node itself by learning the information of adjacent nodes, generating new features that consider the interaction between similar text nodes, which can effectively increase the accuracy of sentiment classification.
[0028] 2) Through the comparative learning module, the category features learned by the model are better extended to different target data, further improving the accuracy and generalization of classification.
[0029] 3) The traditional LDA model cannot better combine contextual information in long texts. By introducing the BERT pre-trained model, the contextual information of the text is integrated to enhance the accuracy of topic clustering. Most public opinion data are opinions expressed on a certain event, so there are large common features between the data. The public opinion data is divided into topics through topic clustering, and then the data of different topics are introduced into the graph neural network to learn the interaction between similar nodes and the common features between the same topics. Finally, the feature representation that integrates the commonality of the topic and the similarity of the text is obtained to improve the accuracy of the model. BRIEF DESCRIPTION OF THE DRAWINGS
[0030] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0031] Figure 1 Schematic diagram of the principle of the method for joint analysis of public opinion topics and sentiment tendencies in an embodiment of the present invention;
[0032] Figure 2 Flow chart of the method for joint analysis of public opinion topics and sentiment tendencies in an embodiment of the present invention;
[0033] Figure 3 Schematic diagram of a neural network model in the figure according to an embodiment of the present invention. DETAILED DESCRIPTION
[0034] In order to enable those skilled in the art to better understand the scheme of the present invention, the technical scheme in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of the present invention.
[0035] It should be noted that the terms "first", "second", etc. in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchanged where appropriate, so that the embodiments of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0036] The present invention provides a joint analysis method of public opinion topics and sentiment tendency based on topic models and graph neural networks, and the concept is as follows: first, the BERT pre-training model is used to encode the features of the text, so as to increase the model's ability to extract features and fuse contextual features. Since public opinion data on the same topic have relatively large common features, the topic classification results are used to learn the commonalities of public opinion data under different topics, thereby increasing the model's ability to classify public opinion data. Since there is a certain correlation between different texts of the same category in the sentiment classification task of public opinion texts, by introducing a graph neural network to fuse the feature representations of different texts, a fusion module is set to update the feature representation of the node itself by learning the information of adjacent nodes, and new features that consider the interaction between similar text nodes are generated, which can effectively increase the accuracy of public opinion sentiment classification. In order to increase the generalization ability of the model and make full use of text similarity, a comparative learning module is introduced to better extend the category features learned by the model to different target data, further improving the accuracy of classification.
[0037] Specifically, an embodiment of the present invention provides a method for jointly analyzing public opinion topics and sentiment tendencies based on a topic model and a graph neural network. Figure 1 , Figure 2 As shown, the specific steps include:
[0038] S1 obtains a corpus including public opinion text data;
[0039] The specific steps of obtaining the corpus in this embodiment are as follows:
[0040] S1.1 Obtain relevant news sets through news databases, build news dictionaries, and select news data with high relevance as data sets;
[0041] Among them, news usually refers to reports about recent events. It has the characteristics of timeliness, authenticity, objectivity, importance and simplicity. News can be disseminated through various channels, including but not limited to newspapers, television, radio, the Internet and social media. News agencies and journalists are responsible for collecting, editing and publishing news to meet the public's demand for information. In the embodiment of the present invention, news is used as the corpus to be analyzed, and the emotional tendency of the public opinion text is accurately identified by jointly analyzing the public opinion theme and emotional tendency of the public opinion text.
[0042] S1.2 preprocess the data to obtain the corpus;
[0043] Specifically, preprocessing includes: data cleaning, removing noise data; segmenting the text and removing stop words.
[0044] S2. Use the BERT pre-training model to fully mine the text context feature information of the corpus as the node set of the opinion graph;
[0045] The BERT pre-trained model is an advanced language representation model based on the Transformer architecture, and its full name is Bidirectional Encoder Representations from Transformers. BERT has learned rich language representations through pre-training on a large amount of text data, and can capture the semantic relationship between words in different contexts.
[0046] In the embodiment of the present invention, BERT and the training model are used to encode the contextual information of words and sentences in the text, including the words and sentences in the previous and next contexts, which helps the model understand the complex context in the text. Generate the feature vector V of the public opinion text (see formula 1), and use the feature vectors of all texts as the node set of the public opinion graph:
[0047] V=BERT(t)=[V1,V2,...,V n ] (1)
[0048] S3. Build a BERT-LDA model for fine-grained topic analysis.
[0049] The LDA model, or Latent Dirichlet Allocation model, is a document generation model that belongs to unsupervised machine learning technology. LDA believes that a document is generated by a mixture of multiple topics, and each topic corresponds to a specific set of vocabulary distributions. The generation process of each word in a document can be regarded as first selecting a topic from the topic distribution of the document, and then selecting a word from the vocabulary distribution corresponding to the topic.
[0050] In an embodiment of the present invention, the text features extracted by the BERT pre-training model are fused with the LDA model to perform topic clustering analysis, so as to combine the public opinion topic with the news report context and obtain classified topics with text features. Classified topics with text features generally refer to using features in text data to identify and classify different topics or categories to which the text belongs. Text features may include word frequency, TF-IDF value, distribution of words, grammatical structure, semantic information, etc. Through these features, the LDA model can be trained to predict the topic of the text. For example, news articles may be classified into different categories such as sports and entertainment.
[0051] In order to evaluate the prediction and generalization capabilities of the model, perplexity is introduced in the embodiment of the present invention. Perplexity calculation is often used to evaluate the prediction and generalization capabilities of the LDA model. The lower the perplexity, the better the model performance.
[0052] In the specific implementation, the perplexity calculation (see formula (2)) determines the optimal number of topics k:
[0053]
[0054] Where D is the set of all words in the document, M is the number of documents, and w d is the word in document D, N d is the number of words in D in each document, p(w d ) is the probability of a word appearing in a document.
[0055] When calculating accuracy, precision, recall, and macro F1, the predicted value needs to be changed to 0 or 1. With 0.5 as the dividing line, predicted values greater than 0.5 become 1, and predicted values less than 0.5 become 0. The calculation formulas for accuracy, precision, recall, and macro F1 are as follows:
[0056]
[0057] In the above equation, the definitions of TP, FP, TN, and FN are shown in Table 1:
[0058] Table 1
[0059]
[0060] S4, using the text feature vector V obtained in S2 and the topic features obtained in S3 to construct a public opinion feature map, and input it into the graph neural network for convolution to obtain fusion features;
[0061] like Figure 3 As shown, in the embodiment of the present invention, a three-layer graph neural network model is introduced to learn node embedding for feature fusion, and feature information that considers the interaction between similar text nodes is output. During the training phase, the features are subjected to contrast loss calculation to improve the generalization of the model.
[0062] In a specific embodiment, the steps are as follows:
[0063] S41, calculating the semantic similarity between different nodes in the opinion graph node set by cosine distance (see formula (7));
[0064] S42, when the distance between two nodes is within a specific range, construct an edge of the semantic relationship between the two nodes (see formula (8));
[0065] S43, constructing a public opinion feature graph by combining text feature nodes and semantic relationship edges;
[0066] S44, introducing a graph neural network module to learn node embedding and update nodes on the constructed public opinion feature graph;
[0067] S45. Based on the updated nodes, output a fusion public opinion feature graph with interactions between similar text nodes (see formula (9)):
[0068]
[0069] Among them, t is the public opinion text data, V is the feature vector of the public opinion text, n is the vector dimension, V i ′ is the fusion node feature generated by GCN, E ij is a semantic relationship edge, represents the feature of node j in layer l, σ represents nonlinear transformation, c ij is the normalization factor, N i represents node i and its neighboring node set, w (l) represents the weight of the lth layer, b (l) represents the intercept of the lth level.
[0070] S46. Introduce the contrast loss function to perform contrastive learning on the hidden vector based on the sentiment label information of the source data set.
[0071] In contrastive learning, data with the same sentiment label in the dataset is classified as positive samples, and others are classified as negative samples. For a V i ∈H, if Vt and V i have the same sentiment label, i.e. y i =y t Then V i Considered to be V t positive example, while other examples V x ∈H is considered a negative example. Calculate all positive examples (V t , V i ) and (V i and V t )’s contrast loss (see formula (10)(11)).
[0072]
[0073] 1 of them [t≠i] ∈(0,1) is the indicator function, sim(V t ,V i ) Calculate the vector V t and V i The cosine similarity of .
[0074] S5. Input the final fused feature vector into the classifier for classification, use the cross entropy loss function as the classifier loss function, and output the sentiment classification.
[0075] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.
Claims
1. A joint analysis method of topic and sentiment tendency, characterized in that: include: Collect and preprocess the public opinion text data to be analyzed to obtain a corpus; Encoding the text data in the corpus using the BERT pre-trained model to obtain a text feature vector with contextual relationship; Input the text feature vector into the LDA model to extract the topic features of the text; Using the text feature vector and the topic feature, constructing a public opinion feature graph by calculating text similarity; Constructing and training a graph convolutional neural network; the graph convolutional neural network takes the public opinion feature graph as input, fuses feature representations of different texts, learns adjacent node information to update its own node representation, and generates fused features with interactions between similar texts; Input the fused features into a classifier to obtain a sentiment tendency classification of the text; The types of emotional tendencies include: negative and positive.
2. A method for joint analysis of topics and sentiment tendency according to claim 1, characterized in that: Also includes: Optimize the LDA model using perplexity calculation.
3. The method for joint analysis of topic and sentiment tendency according to claim 1, characterized in that: Using the text feature vector and the topic feature, constructing a public opinion feature graph through text similarity calculation includes: Calculating semantic similarity between different nodes in a public opinion graph node set by cosine distance; the public opinion graph node set is composed of the text feature vector; When the distance between two nodes is within a specific range, an edge of the semantic relationship between the two points is constructed; The text feature nodes and semantic relationship edges are used to construct a public opinion feature graph.
4. The method for joint analysis of topic and sentiment tendency according to claim 1, characterized in that: The graph convolutional neural network is a three-layer graph neural network.
5. A method for joint analysis of topics and sentiment tendency according to claim 4, characterized in that: The loss function used when training the graph convolutional neural network is a contrast loss function.
6. A method for joint analysis of topics and sentiment tendency according to claim 5, characterized in that: Training the graph convolutional neural network includes: In contrastive learning, data with the same sentiment label in the dataset is classified as positive samples, and others are classified as negative samples; given a small batch of text hidden vectors For a V i ∈H, if V t and V i have the same sentiment label, i.e. y i =y t Then V i Considered to be V t positive example, while other examples V x ∈H is considered a negative example; calculate all positive examples (V t , V i ) and (V i and V t )’s contrast loss: 1 of them [t≠i] ∈(0,1) is the indicator function, sim(V t ,V i ) Calculate the vector V t and V i The cosine similarity of .
7. A method for joint analysis of topics and sentiment tendency according to claim 1, characterized in that: The cross entropy loss function is used as the loss function of the classifier.
Citation Information
Cited By
Generative AI-based emotion connection interaction method, system and equipment
CN119166824A
