Social network user text sentiment analysis method and device

By constructing a directed graph structure and a dynamic bidirectional graph attention network of a social network, combining K-shell value and local clustering coefficient filtering node annotation, the structure and correlation are not considered in text sentiment analysis of social network users in the prior art. The problem of the problem improves the accuracy of emotional judgment and the performance of the prediction model.

CN119128151APending Publication Date: 2024-12-13CHINA STATE SHIPBUILDING CORP LTD RESEARCH INSTITUTE 719
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202411177738.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-26
Publication Date
2024-12-13

AI Technical Summary

Technical Problem

The prior art fails to effectively consider the structure of the social network and the relevance of text in the network in the sentiment analysis of social network user texts, resulting in inaccurate or incorrect emotional judgment results.

Method used

By constructing a directed graph structure of a social network, the K-shell value and local clustering coefficient of user nodes are calculated, important nodes are screened for annotation, semi-supervised neural network loss function is constructed, and dynamic bidirectional graph attention network is used for prediction, combined with Sentiment analysis was performed on social network structure and text characteristics.

Benefits of technology

It improves the accuracy of emotional judgment, uses the structural characteristics of social media communication graph data to capture the potential relationship between user texts, enhances the performance of the prediction model, and is suitable for public opinion environment analysis and content control.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119128151A_ABST
    Figure CN119128151A_ABST
Patent Text Reader

Abstract

The invention provides a social network user text sentiment analysis method and device. According to the method, the structure of a social network is considered in the aspects of selection of annotation data and construction of a dynamic two-way attention network. Wherein in the aspect of data labeling, part of data is selected to be labeled based on K-shell and local clustering coefficients in a graph structure, data with higher importance and aggregation degree is selected to be trained, and the effect is better. In the aspect of prediction network design, a dynamic bidirectional attention network is designed by utilizing a social network graph structure, the structural characteristics of social media propagation graph data are utilized to a great extent, and potential relationships between user texts are captured, so that the accuracy of emotion judgment is improved. Therefore, the accuracy of emotion judgment can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data analysis, and in particular to a method and device for analyzing sentiment of user texts in a social network. Background Art

[0002] With the rapid development and popularization of the Internet, a large number of online social networks have emerged, which have become the main platform for people to share, disseminate and obtain information. Users can post texts on the platform to express their emotions, and a large number of users also express their emotions indirectly through behaviors such as likes, forwarding and comments.

[0003] Existing technologies for sentiment analysis of social network user texts are mainly concentrated in the field of natural language processing. By segmenting the text and marking its polarity, sentiment dictionaries, machine learning, deep learning and other methods are used to analyze the sentiment contained in a text. Accurate sentiment analysis of social networks is of great significance in the fields of market research, public opinion control and so on.

[0004] Most existing methods judge the sentiment of social network texts alone, without considering the structure of the social network and the relevance of the texts in the social network, resulting in inaccurate or even wrong sentiment judgment results. Summary of the invention

[0005] In view of this, the present invention provides a method for sentiment analysis of social network user texts, which can improve the accuracy of sentiment judgment.

[0006] In order to solve the above technical problems, the present invention is implemented as follows.

[0007] A method for sentiment analysis of social network user text, comprising:

[0008] Step 1: Based on the social network propagation relationship data, a social network directed graph structure is constructed; the structural characteristics of each user node in the social network directed graph structure are calculated, including the K-shell value and the local clustering coefficient; the user basic attributes and structural characteristics of the user node constitute a user feature vector sequence;

[0009] Step 2: According to the K-shell value and the local clustering coefficient, select a set number or proportion of user nodes with larger K-shell value and local clustering coefficient, and annotate the text sentiment attributes for the user feature vector sequences of these users; the user feature vector sequence and the annotated text sentiment attributes constitute the training sample;

[0010] Step 3: Construct a semi-supervised neural network loss function based on the directed graph structure of the social network and the annotations in step 2;

[0011] Step 4: Based on the directed graph structure of the social network, a dynamic bidirectional graph attention network is constructed as a prediction network to distinguish the attention weights of each user to the out-degree neighbors and in-degree neighbors; the prediction network is trained and optimized based on training samples and a semi-supervised neural network loss function;

[0012] Step 5: During analysis, extract the user’s user feature vector sequence and input it into the prediction network to predict the sentiment type of the user’s text.

[0013] Preferably, in step 1, the K-shell value is calculated according to the directed graph structure of the social network as follows:

[0014] Determine the degree of each user node in the directed graph structure of the social network; the degree is the number of other user nodes directly connected to the current user node;

[0015] Recursively remove user nodes: Let the k value be the minimum value of the degree of all nodes in the directed graph structure of the social network, remove all user nodes with a degree of k, and mark the K-shell values ​​of these user nodes as k; after each removal, recalculate the degree of each user node in the remaining part of the directed graph structure of the social network until there is no user node with a degree equal to k in the current directed graph structure of the social network;

[0016] Update the k value to the minimum value of all node degrees in the current social network directed graph structure, remove all user nodes with degree k, and mark the K-shell values ​​of these user nodes as the current k value, and repeat this process; complete the K-shell value labeling of all user nodes.

[0017] Preferably, in step 1, the local clustering coefficient is calculated according to the directed graph structure of the social network by:

[0018]

[0019] Among them, C v represents the local clustering coefficient of node v, e represents the number of edges actually existing between all nodes adjacent to node V, and k(v) represents the degree of node v in the directed graph structure of the social network, that is, the total number of other nodes directly connected to node v.

[0020] Preferably, in step 2, the user nodes having a set number or proportion with larger K-shell values ​​and local clustering coefficients are selected as follows:

[0021] According to the K-shell value and local clustering coefficient, the top 20% of user nodes are screened out and the text sentiment attributes are labeled.

[0022] Preferably, in step 3, the constructed semi-supervised neural network loss function consists of three parts, namely, a cross entropy loss function term L1 based on labeled data, a mean square error loss function term L2 based on clustering assumption, and a total variation loss function term L3 based on smoothness assumption;

[0023] For a set number or proportion of labeled data, the cross entropy loss function term L1 is as follows:

[0024]

[0025] Among them, V L is the set of labeled user nodes, y l is the annotation label of the user node in the set of annotated user nodes, is the corresponding predicted label, and H is the cross entropy calculation function;

[0026] Based on the clustering hypothesis, considering that the classification result remains unchanged after adding perturbations to the same data, the mean square error loss function term L2 is as follows:

[0027]

[0028] Among them, d MSE is the mean square error calculation function, V U is the set of unlabeled user nodes, is the predicted label of the user node in the set of unlabeled user nodes, is the corresponding predicted label after adding Gaussian noise to the unlabeled user node during the embedding process;

[0029] Based on the smoothness assumption, the total variation loss function term L3 is as follows:

[0030]

[0031] Among them, V is the set of all user nodes, ω ij is the weight coefficient of user nodes i and j, y is the matrix composed of user feature vector sequences of all user nodes, and L is the Laplace matrix of the constructed social network directed graph structure.

[0032] Preferably, in step 4, the cross entropy loss function term L1, the mean square error loss function term L2 and the total variation loss function term L3 are weighted to construct a semi-supervised neural network loss function for training the dynamic bidirectional graph attention network. as follows:

[0033]

[0034] Among them, the L1 weight is fixed to 1, η and μ are weight coefficients to prevent overfitting, and μ is time-varying and decreases with the number of training times.

[0035] Preferably, the dynamic bidirectional graph attention network constructed in step 4 modifies the operation order of the network layer in the graph attention network, and the dynamic bidirectional attention α of the dynamic bidirectional graph attention network ij Out and ij In The calculation is as follows:

[0036]

[0037] Among them, e Out (h i ,h j ) and e In (h i ,h j ) is the intermediate quantity; h i and h j is the representation of user node i, j in the network layer, LeakyReLU is the activation function, ∥ represents the vector concatenation operation, a1 T , a2 T , W1, W2 are the parameters of neural network training and learning, and are the out-degree neighborhood set and in-degree neighborhood set of user node i respectively, and exp is an exponential function.

[0038] Preferably, in the dynamic bidirectional graph attention network, the user node representation vector update rule is:

[0039]

[0040] Among them, h i (m+1) is the representation vector of user node i in the m+1th layer of the dynamic bidirectional graph attention network, λ and θ are the defined out-degree attention weight and in-degree attention weight coefficients.

[0041] The present invention also provides a social network user text sentiment analysis device, including a directed graph structure and user feature vector embedding module, a semi-supervised user node screening module, a loss function construction module, a dynamic two-way attention module, an optimization module and a prediction module;

[0042] The directed graph structure and user feature vector embedding module is used to construct a social network directed graph structure based on social network propagation relationship data; calculate the structural features of each user node in the social network directed graph structure, including K-shell value and local clustering coefficient; the user basic attributes and structural features of the user node constitute a user feature vector sequence;

[0043] The semi-supervised user node screening module is used to screen out a set number or proportion of user nodes with larger K-shell values ​​and local clustering coefficients according to the K-shell values ​​and local clustering coefficients, and mark the text sentiment attributes; the user feature vector sequence and the marked text sentiment attributes constitute a training sample;

[0044] The loss function construction module is used to construct respective loss function terms for the labeled data, unlabeled data and all data in the user feature vector sequence according to the directed graph structure of the social network and the labeling of some user nodes, and then synthesize and obtain the semi-supervised neural network loss function;

[0045] The dynamic bidirectional attention module is used to construct a dynamic bidirectional graph attention network as a prediction network based on the directed graph structure of the social network, and distinguish the attention weights of each user to the out-degree neighbors and the in-degree neighbors;

[0046] The optimization module is used to train and optimize the prediction network using the training samples and the semi-supervised neural network loss function;

[0047] The prediction module is used to extract the user feature vector sequence of the user by using the directed graph structure and the user feature vector embedding module, input the sequence into the prediction network constructed by the dynamic bidirectional attention module, and predict the emotion type of the user text.

[0048] Preferably, the semi-supervised neural network loss function constructed by the loss function construction module consists of three parts, namely, a cross entropy loss function term L1 based on labeled data, a mean square error loss function term L2 based on a clustering assumption, and a graph total variation loss function term L3 based on a smoothness assumption;

[0049] For a set number or proportion of labeled data, the cross entropy loss function term L1 is as follows:

[0050]

[0051] Among them, V L is the set of labeled user nodes, y l is the annotation label of the user node in the set of annotated user nodes, is the corresponding predicted label, and H is the cross entropy calculation function;

[0052] Based on the clustering hypothesis, considering that the classification result remains unchanged after adding perturbations to the same data, the mean square error loss function term L2 is as follows:

[0053]

[0054] Among them, d MSE is the mean square error calculation function, V Uis the set of unlabeled user nodes, is the predicted label of the user node in the set of unlabeled user nodes, is the corresponding predicted label after adding Gaussian noise to the unlabeled user node during the embedding process;

[0055] Based on the smoothness assumption, the total variation loss function term L3 is as follows:

[0056]

[0057] Among them, V is the set of all user nodes, ω ij is the weight coefficient of user nodes i and j, y is the matrix composed of user feature vector sequences of all user nodes, and L is the Laplace matrix of the constructed social network directed graph structure;

[0058] Then the loss function of the semi-supervised neural network as follows:

[0059]

[0060] Among them, the L1 weight is fixed to 1, η and are weight coefficients to prevent overfitting, and μ is time-varying and decreases with the number of training times.

[0061] Beneficial effects:

[0062] (1) The present invention does not use text alone to judge emotions, but takes into account the structure of social networks and the relevance of text in social networks. The structure of social networks is considered in both the selection of labeled data and the construction of a dynamic two-way attention network. Among them, in terms of labeled data, based on the graph structure, including importance (K-shell) and clustering (local clustering coefficient), part of the data is selected for labeling, and data with higher importance and clustering are selected for training, which has better results. In terms of predictive network design, unlike existing sentiment analysis methods, the present invention uses a social network graph structure to design a dynamic two-way attention network, which can greatly utilize the structural characteristics of social media communication graph data to capture the potential relationship between user texts, thereby improving the accuracy of sentiment judgment.

[0063] (2) When constructing the neural network loss function, the present invention designs the loss function term for unlabeled data based on the clustering hypothesis and designs the loss function term based on the smoothness hypothesis. The clustering hypothesis takes into account that the classification structure remains unchanged after the same data is perturbed, and the smoothness hypothesis takes into account the continuity and smoothness of the function output change. The consideration of the clustering hypothesis and the smoothness hypothesis makes the optimization effect of the prediction model using the loss function faster and more accurate.

[0064] (3) The present invention facilitates the analysis of the public opinion environment of the content, helps the platform to achieve more accurate control of the content, and also promotes the development of social media platforms. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] Figure 1 A flow chart of a method for analyzing sentiment of user texts on a social network provided by an embodiment of the present invention is shown;

[0066] Figure 2 A schematic diagram of a model structure of a method for sentiment analysis of user texts on a social network provided by an embodiment of the present invention is shown;

[0067] Figure 3 A schematic structural diagram of a device for analyzing sentiment of user texts in a social network provided by an embodiment of the present invention is shown. DETAILED DESCRIPTION

[0068] The present invention provides a social network user text sentiment analysis solution, which adopts a semi-supervised method to train the prediction network. The prediction network adopts a dynamic two-way attention network. The structure of the social network is considered in the construction of the dynamic two-way attention network and the screening of the labeled data for semi-supervised learning. Among them, in terms of labeled data, based on the graph structure, including importance (K-shell) and clustering (local clustering coefficient), part of the data is selected for labeling, and data with higher importance and clustering are selected for training, which has better effect. In terms of predictive network design, unlike the existing sentiment analysis methods, the present invention uses a social network graph structure to design a dynamic two-way attention network, which can make full use of the structural characteristics of social media communication graph data to capture the potential relationship between user texts, thereby improving the accuracy of sentiment judgment. According to the social network communication relationship data, a social network directed graph structure is constructed, and based on the social network directed graph structure, it is performed

[0069] It can be seen that the present invention does not use text alone to judge emotions, but takes into account the structure of social networks and the relevance of texts in social networks. The present invention selects data with higher importance and aggregation for annotation based on the graph structure, so that the effect of the supervised learning part is better under the condition of limited training samples. The dynamic bidirectional attention network designed based on the graph structure fully captures the potential relationship between user texts and improves the accuracy of the prediction network.

[0070] Furthermore, when constructing a neural network loss function, the present invention designs loss function terms for unlabeled data based on the clustering hypothesis and designs loss function terms based on the smoothness hypothesis. The clustering hypothesis takes into account that the classification structure remains unchanged after the same data is perturbed, and the smoothness hypothesis takes into account the continuity and smoothness of the function output change. The consideration of the clustering hypothesis and the smoothness hypothesis makes the optimization effect of the prediction model using the loss function faster and more accurate.

[0071] The present invention is described in detail below with reference to the accompanying drawings and embodiments.

[0072] Figure 1 The flowchart of the method for analyzing sentiment of social network user texts of the present invention is shown. Figure 1 As shown, the method comprises the following steps:

[0073] Step 1: Construct a directed graph structure of a social network based on the propagation relationship data of the social network; calculate the structural characteristics of each user node in the directed graph structure of the social network, including the K-shell value and the local clustering coefficient; the basic attributes and structural characteristics of the user nodes constitute the user feature vector sequence.

[0074] This step includes the following steps:

[0075] Step 101: Obtain social network communication relationship data and user basic information, and construct a social network directed graph structure based on the social network communication relationship data.

[0076] Among them, social network communication relationship data refers to the history of interaction between users in social media, including forwarding, liking, commenting content, etc. Social network communication relationship data can be stored using a graph data structure. In the graph data, each node represents a single user, which is called a user node in the present invention, and the edges represent the relationship characteristics between users. The edges are determined based on actions such as forwarding and liking. For example, the target is used to determine who to connect with, right? Does the edge also have a direction? For example, if A likes B, an edge from A to B appears. If A and B comment on each other, two edges will appear, one from A to B and one from B to A.

[0077] For user nodes, basic user attributes are embedded in the user nodes as part of the user node representation vector. Basic user attributes may include, for example, user registration gender, registration address, number of likes, number of followers, and posting time.

[0078] Step 102: Calculate the structural features of each user according to the directed graph structure of the social network. The structural features selected by the present invention include the k-shell value and the local clustering coefficient.

[0079] Specifically, the K-shell value is an important indicator for measuring node centrality in complex network analysis. It evaluates the importance of nodes based on the "shell" position of the nodes. In K-shell decomposition, the nodes in the network are assigned to different shells according to their connection patterns. The larger the shell number, the more important the node in the core position of the network is. The calculation method of K-shell value is as follows:

[0080] First, determine the degree of each node in the network, that is, the number of other nodes that are directly connected to it.

[0081] Then, recursively remove nodes: let the k value be the minimum value of the degree of all nodes in the directed graph structure of the social network, generally starting from 1, and the degree of 1 is a node with only one neighbor. First, remove all nodes with degree k, and mark these nodes with K-shell value k; after removing some nodes, the degree of other nodes may decrease. Therefore, after each removal, recalculate the degree of each node in the remaining network until there are no more nodes with degree equal to k in the current network; next, update the k value to the current minimum degree, remove the nodes with current degree k, which may be nodes with degree 2 at this time, mark them with K-shell value as the current k value, and repeat this process; when the remaining nodes are no longer reduced to the extent that they can be removed, mark their k-shell value as the current k value. For example, after removing all nodes with degree 1, there are three nodes left to form a triangle structure, the degree of all three nodes is 2, and all three nodes can no longer be removed, so their k-shell values ​​are marked as 2. When all nodes in the network are assigned K-shell values, the process ends.

[0082] Specifically, the local clustering coefficient is an important indicator in complex network analysis, which is used to quantify the density of connections between neighboring nodes of a node in the network, reflecting the cohesion or aggregation degree of the local area of ​​the node. It is calculated as follows:

[0083]

[0084] Among them, C v represents the local clustering coefficient of node v, e represents the number of edges actually existing between all nodes adjacent to node v, k(v) represents the degree of node v, that is, the total number of other nodes directly connected to node v, and the "2" in the numerator is to correct the bias introduced by counting each edge twice in the calculation.

[0085] Step 103: Combine the basic user information and the directed graph structure of the social network to obtain a user feature vector sequence of each user node. The user feature vector sequence includes the basic user information, as well as the k-shell value and clustering coefficient of the user node.

[0086] Step 2: According to the K-shell value and the local clustering coefficient, select a set number or proportion of user nodes with larger K-shell value and local clustering coefficient, and annotate the text sentiment attributes for the user feature vector sequences of these users. The user feature vector sequence and the annotated text sentiment attributes constitute the training samples for semi-supervised learning.

[0087] In a preferred embodiment, the top 20% of nodes are screened out for manual sentiment labeling based on the K-shell value and local clustering coefficient of the user nodes.

[0088] Step 3: Construct a semi-supervised neural network loss function based on the social network directed graph structure and the annotations in step 2.

[0089] In this step, according to the directed graph structure of the social network and the emotional attributes of the annotated user nodes, a semi-supervised neural network loss function is constructed based on the clustering hypothesis and the smoothness hypothesis, and weight coefficients are added to each item of the loss function to prevent overfitting.

[0090] Specifically, the semi-supervised neural network loss function consists of three parts: the cross entropy loss function term L1 based on the labeled data, the mean square error loss function term L2 based on the clustering assumption, and the total variation loss function term L3 based on the smoothness assumption.

[0091] For a set number or proportion (e.g., the first 20%) of labeled data, the cross entropy loss function term L1 is as follows:

[0092]

[0093] Among them, V L is the set of labeled user nodes, |V L | represents the set V L The number of users in y l is the annotation label of the user node in the set of annotated user nodes, is the corresponding predicted label, and H is the cross entropy calculation function.

[0094] Based on the clustering hypothesis, similar samples in the set should belong to the same category or cluster, while different samples should belong to different categories. Therefore, the classification result should remain unchanged after adding perturbations to the same data. Therefore, the mean square error loss function term L2 is as follows:

[0095]

[0096] Among them, d MSE is the mean square error calculation function, V U is the set of unlabeled user nodes, |V U | represents the set V U The number of users in is the predicted label of the user node in the set of unlabeled user nodes, It corresponds to the predicted label after adding Gaussian noise to the unlabeled user node during the embedding process.

[0097] Based on the smoothness assumption, if two data points are close enough in the feature space, their output labels should also be similar. In other words, the output change of the function should be continuous and smooth, without sudden and unreasonable jumps. Therefore, the total variation loss function term L3 is as follows:

[0098]

[0099] Among them, V is the set of all user nodes, ω ij is the weight coefficient of user nodes i and j, y is the matrix composed of user feature vector sequences of all user nodes, and L is the Laplace matrix of the constructed social network directed graph structure.

[0100] Therefore, the total loss function as follows:

[0101]

[0102] Among them, the L1 weight is fixed to 1, η and μ are weight coefficients to prevent overfitting. In order to gradually reduce the weight of the total variation loss function term of the graph, μ is time-varying and decreases with the number of training times.

[0103] Step 4: Based on the directed graph structure of the social network, a dynamic bidirectional graph attention network is constructed as a prediction network to distinguish the attention weights of each user to out-degree neighbors and in-degree neighbors. The prediction network is trained and optimized based on training samples and a semi-supervised neural network loss function.

[0104] Graph Attention Network (GAT) is an advanced Graph Neural Network (GNN) model that enhances the model's ability to capture node-to-node relationships and feature information by introducing an attention mechanism between nodes. GAT introduces learnable attention weights for each edge in the graph. This means that the model can dynamically determine the influence of a node's neighbor nodes on it during information transmission, thereby more flexibly capturing complex relationship patterns between nodes. Through the attention coefficient, GAT assigns a weight to each neighbor node, which reflects how the current node should value the neighbor's information when aggregating neighbor information. This enables the model to adaptively adjust the degree of attention to different neighbors in each propagation step.

[0105] The dynamic graph attention network modifies the order of network layer operations based on GAT and exchanges a T The order of operations of the linear layer and the LeakyReLU layer makes up for the problem that the attention weights calculated by GAT have the same relative ranking among different nodes but different absolute values.

[0106] However, the dynamic graph attention network still assumes that the sum of the user's attention to all neighbor nodes is certain, which is inconsistent with the actual situation of social networks, because the sum of the attention of the same user to the out-degree neighbors and the in-degree neighbors should be independent. Therefore, the present invention distinguishes between dynamic out-degree attention and dynamic in-degree attention, and constructs a dynamic bidirectional attention network, whose dynamic bidirectional attention α ij Out and α ij In The calculation is as follows:

[0107]

[0108] Among them, e Out (h i ,h j ) and e In (h i ,h j ) is the intermediate quantity; h i and h j is the representation of user node i, j in the network layer, LeakyReLU is the activation function, ∥ represents the vector concatenation operation, a1 T , a2 T , W1, W2 are the parameters of neural network training and learning, a1 T , a2 T is the linear weighting coefficient, W1, W2 are the matrix weight parameters, and exp is the exponential function; and They are the out-degree neighborhood set and in-degree neighborhood set of user node i respectively. The edges of a directed graph have their own directions. There are out-degree areas and in-degree areas. For A→B, A is in the in-degree neighborhood of B, and B is in the out-degree neighborhood of A.

[0109] The feature vectors and labels of labeled user nodes form training samples. Gaussian noise is added to the feature vectors of unlabeled user nodes. By distinguishing out-degree attention and in-degree attention, two dynamic attention layers are used for calculation respectively. The calculation results are aggregated and updated to a new user feature vector sequence; the new user node representation vector is used to predict the user text sentiment.

[0110] The update rule of the above user feature vector sequence is:

[0111]

[0112] Among them, h i (m+1)is the representation vector of user node i in the m+1th layer of the dynamic bidirectional graph attention network, λ and θ are the defined out-degree attention weight and in-degree attention weight coefficients, which are generally selected manually. The m layer here is the training layer of the graph neural network. It is necessary to perform iterative calculations and training in multiple training layers to finally obtain the prediction results.

[0113] Step 5: During analysis, extract the user’s user feature vector sequence and input it into the prediction network to predict the sentiment type of the user’s text.

[0114] Based on the above method, the present invention also provides a device for analyzing sentiment of social network user texts. Figure 3 As shown, the device includes a directed graph structure and user feature vector embedding module, a semi-supervised user node screening module, a loss function construction module, a dynamic bidirectional attention module and a prediction module.

[0115] The directed graph structure and user feature vector embedding module is used to construct a social network directed graph structure based on social network propagation relationship data; calculate the structural characteristics of each user node in the social network directed graph structure, including the K-shell value and the local clustering coefficient; the user basic attributes and structural characteristics of the user node constitute a user feature vector sequence.

[0116] The semi-supervised user node screening module is used to screen out a set number or proportion of user nodes with larger K-shell values ​​and local clustering coefficients according to the K-shell values ​​and local clustering coefficients, and mark the text sentiment attributes; the user feature vector sequence and the marked text sentiment attributes constitute the training sample.

[0117] The loss function construction module is used to construct respective loss function terms for the labeled data, unlabeled data and all data in the user feature vector sequence according to the directed graph structure of the social network and the annotations of some user nodes, and then synthesize them to obtain the semi-supervised neural network loss function.

[0118] The dynamic bidirectional attention module is used to build a dynamic bidirectional graph attention network as a prediction network based on the directed graph structure of the social network, and distinguish the attention weights of each user to the out-degree neighbors and in-degree neighbors.

[0119] The optimization module is used to train and optimize the prediction network using the training samples and the semi-supervised neural network loss function.

[0120] The prediction module is used to extract the user feature vector sequence of the user by using the directed graph structure and the user feature vector embedding module, input the sequence into the prediction network constructed by the dynamic bidirectional attention module, and predict the emotion type of the user text.

[0121] Among them, the process of calculating the K-shell value and the local clustering coefficient of the directed graph structure and the user feature vector embedding module has been described above and will not be described in detail here.

[0122] The semi-supervised neural network loss function constructed by the loss function construction module consists of three parts: the cross entropy loss function term L1 based on the labeled data, the mean square error loss function term L2 based on the clustering assumption, and the total variation loss function term L3 based on the smoothness assumption;

[0123] For a set number or proportion of labeled data, the cross entropy loss function term L1 is as follows:

[0124]

[0125] Among them, V L is the set of labeled user nodes, |V L | represents the set V L The number of users in y l is the annotation label of the user node in the set of annotated user nodes, is the corresponding predicted label, and H is the cross entropy calculation function;

[0126] Based on the clustering hypothesis, considering that the classification result remains unchanged after adding perturbations to the same data, the mean square error loss function term L2 is as follows:

[0127]

[0128] Among them, d MSE is the mean square error calculation function, V U is the set of unlabeled user nodes, |V U | represents the set V U The number of users in is the predicted label of the user node in the set of unlabeled user nodes, is the corresponding predicted label after adding Gaussian noise to the unlabeled user node during the embedding process;

[0129] Based on the smoothness assumption, the total variation loss function term L3 is as follows:

[0130]

[0131] Among them, V is the set of all user nodes, ω ij is the weight coefficient of user nodes i and j, y is the matrix composed of user feature vector sequences of all user nodes, and L is the Laplace matrix of the constructed social network directed graph structure;

[0132] Then the loss function of the semi-supervised neural network as follows:

[0133]

[0134] Among them, the L1 weight is fixed to 1, η and μ are weight coefficients to prevent overfitting, and μ is time-varying and decreases with the number of training times.

[0135] Dynamic Bidirectional Attention α of Dynamic Bidirectional Graph Attention Network constructed by Dynamic Bidirectional Attention Module ij Out and α ij In The calculation method is as described above and will not be repeated here.

[0136] The above specific embodiments only describe the design principle of the present invention. The shapes and names of the components in the description may be different and are not limited. Therefore, those skilled in the art in the field of the present invention may modify or replace the technical solutions recorded in the above embodiments; and these modifications and replacements do not deviate from the creative purpose and technical solutions of the present invention and should all fall within the protection scope of the present invention.

Claims

1. A method for sentiment analysis of social network user text, characterized in that: include: Step 1: Construct a directed graph structure of a social network based on the social network propagation relationship data; Calculate the structural features of each user node in the directed graph structure of the social network, including the K-shell value and the local clustering coefficient; the basic attributes and structural features of the user node constitute the user feature vector sequence; Step 2: According to the K-shell value and the local clustering coefficient, select a set number or proportion of user nodes with larger K-shell value and local clustering coefficient, and annotate the text sentiment attributes for the user feature vector sequences of these users; the user feature vector sequence and the annotated text sentiment attributes constitute the training sample; Step 3: Construct a semi-supervised neural network loss function based on the directed graph structure of the social network and the annotations in step 2; Step 4: Based on the directed graph structure of the social network, a dynamic bidirectional graph attention network is constructed as the prediction network to distinguish the attention weights of each user to the out-degree neighbors and in-degree neighbors; Training and optimizing the prediction network based on training samples and a semi-supervised neural network loss function; Step 5: During analysis, extract the user’s user feature vector sequence and input it into the prediction network to predict the sentiment type of the user’s text.

2. The method according to claim 1, characterized in that In step 1, the K-shell value is calculated according to the directed graph structure of the social network as follows: Determine the degree of each user node in the directed graph structure of the social network; the degree is the number of other user nodes directly connected to the current user node; Recursively remove user nodes: Let the k value be the minimum value of all node degrees in the directed graph structure of the social network, remove all user nodes with degree k, and mark the K-shell values ​​of these user nodes as k; After each removal, the degree of each user node in the remaining part of the social network directed graph structure is recalculated until there is no user node with a degree equal to k in the current social network directed graph structure; Update the k value to the minimum value of all node degrees in the current social network directed graph structure, remove all user nodes with degree k, and mark the K-shell values ​​of these user nodes as the current k value, and repeat this process; complete the K-shell value labeling of all user nodes.

3. The method according to claim 1, characterized in that In step 1, the local clustering coefficient is calculated according to the directed graph structure of the social network as follows: Among them, C v represents the local clustering coefficient of node v, e represents the actual number of edges between all nodes adjacent to node v, and k(v) represents the degree of node v in the directed graph structure of the social network, that is, the total number of other nodes directly connected to node v.

4. The method according to claim 1, characterized in that In step 2, the user nodes with a set number or proportion having a larger K-shell value and a larger local clustering coefficient are selected as follows: According to the K-shell value and local clustering coefficient, the top 20% of user nodes are screened out and the text sentiment attributes are labeled.

5. The method according to claim 1, characterized in that In step 3, the constructed semi-supervised neural network loss function consists of three parts, namely, a cross entropy loss function term L1 based on labeled data, a mean square error loss function term L2 based on clustering assumption, and a total variation loss function term L3 based on smoothness assumption; For a set number or proportion of labeled data, the cross entropy loss function term L1 is as follows: Among them, V L is the set of labeled user nodes, |V L | represents the set V L The number of users in y l is the annotation label of the user node in the set of annotated user nodes, is the corresponding predicted label, and H is the cross entropy calculation function; Based on the clustering hypothesis, considering that the classification result remains unchanged after adding perturbations to the same data, the mean square error loss function term L2 is as follows: Among them, d MSE is the mean square error calculation function, V U is the set of unlabeled user nodes, |V U | represents the set V U The number of users in is the predicted label of the user node in the set of unlabeled user nodes, is the corresponding predicted label after adding Gaussian noise to the unlabeled user node during the embedding process; Based on the smoothness assumption, the total variation loss function term L3 is as follows: Among them, V is the set of all user nodes, ω ij is the weight coefficient of user nodes i and j, y is the matrix composed of user feature vector sequences of all user nodes, and L is the Laplace matrix of the constructed social network directed graph structure.

6. The method according to claim 5, characterized in that In step 4, the cross entropy loss function term L1, the mean square error loss function term L2, and the total variation loss function term L3 are weighted to construct a semi-supervised neural network loss function for training the dynamic bidirectional graph attention network. as follows: Among them, the L1 weight is fixed to 1, η and μ are weight coefficients to prevent overfitting, and μ is time-varying and decreases with the number of training times.

7. The method according to claim 1, characterized in that The dynamic bidirectional graph attention network constructed in step 4 exchanges a in the graph attention network T The order of operations of the linear layer and the LeakyReLU layer, the dynamic bidirectional attention α of the dynamic bidirectional graph attention network ij Out and α ij In The calculation is as follows: Among them, e Out (h i ,h j ) and e In (h i ,h j ) is the intermediate quantity; h i and h j is the representation of user nodes i, j in the network layer, LeakyReLU is the activation function, || represents the vector concatenation operation, a1 T , a2 T , W1, W2 are the parameters of neural network training and learning, and are the out-degree neighborhood set and in-degree neighborhood set of user node i respectively, and exp is an exponential function.

8. The method according to claim 7, characterized in that In the dynamic bidirectional graph attention network, the update rule of the user node representation vector is: Among them, h i (m+1) is the representation vector of user node i in the m+1th layer of the dynamic bidirectional graph attention network, λ and θ are the defined out-degree attention weight and in-degree attention weight coefficients.

9. A device for analyzing sentiment of social network user text, characterized in that: It includes directed graph structure and user feature vector embedding module, semi-supervised user node screening module, loss function construction module, dynamic bidirectional attention module, optimization module and prediction module; The directed graph structure and user feature vector embedding module is used to construct a social network directed graph structure based on social network propagation relationship data; calculate the structural features of each user node in the social network directed graph structure, including K-shell value and local clustering coefficient; the user basic attributes and structural features of the user node constitute a user feature vector sequence; The semi-supervised user node screening module is used to screen out a set number or proportion of user nodes with larger K-shell values ​​and local clustering coefficients according to the K-shell values ​​and local clustering coefficients, and mark the text sentiment attributes; the user feature vector sequence and the marked text sentiment attributes constitute a training sample; The loss function construction module is used to construct respective loss function terms for the labeled data, unlabeled data and all data in the user feature vector sequence according to the directed graph structure of the social network and the labeling of some user nodes, and then synthesize and obtain the semi-supervised neural network loss function; The dynamic bidirectional attention module is used to construct a dynamic bidirectional graph attention network as a prediction network based on the directed graph structure of the social network, and distinguish the attention weights of each user to the out-degree neighbors and the in-degree neighbors; The optimization module is used to train and optimize the prediction network using the training samples and the semi-supervised neural network loss function; The prediction module is used to extract the user feature vector sequence of the user by using the directed graph structure and the user feature vector embedding module, input the sequence into the prediction network constructed by the dynamic bidirectional attention module, and predict the emotion type of the user text.

10. The device according to claim 9, characterized in that The semi-supervised neural network loss function constructed by the loss function construction module consists of three parts, namely, a cross entropy loss function term L1 based on labeled data, a mean square error loss function term L2 based on clustering assumption, and a total graph variation loss function term L3 based on smoothness assumption; For a set number or proportion of labeled data, the cross entropy loss function term L1 is as follows: Among them, V L is the set of labeled user nodes, |V L | represents the set V L The number of users in y l is the annotation label of the user node in the set of annotated user nodes, is the corresponding predicted label, and H is the cross entropy calculation function; Based on the clustering hypothesis, considering that the classification result remains unchanged after adding perturbations to the same data, the mean square error loss function term L2 is as follows: Among them, d MSE is the mean square error calculation function, V U is the set of unlabeled user nodes, |V U | represents the set V U The number of users in is the predicted label of the user node in the set of unlabeled user nodes, is the corresponding predicted label after adding Gaussian noise to the unlabeled user node during the embedding process; Based on the smoothness assumption, the total variation loss function term L3 is as follows: Among them, V is the set of all user nodes, ω ij is the weight coefficient of user nodes i and j, y is the matrix composed of user feature vector sequences of all user nodes, and L is the Laplace matrix of the constructed social network directed graph structure; Then the loss function of the semi-supervised neural network as follows: Among them, the L1 weight is fixed to 1, η and μ are weight coefficients to prevent overfitting, and μ is time-varying and decreases with the number of training times.

Citation Information

Cited By

  • Social network trust evaluation method and system based on multi-view neural network

    CN119691683A

  • Social network trust evaluation method and system based on multi-view graph neural network

    CN119691683B